diff --git a/CMakeLists.txt b/CMakeLists.txt index 660637f..6e3b7b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ add_executable( ${PROJECT_SOURCE_DIR}/src/rpn-string.cpp ${PROJECT_SOURCE_DIR}/src/rpn-test.cpp ${PROJECT_SOURCE_DIR}/src/rpn-test-framework.cpp - #${PROJECT_SOURCE_DIR}/src/rpn-time.cpp + ${PROJECT_SOURCE_DIR}/src/rpn-time.cpp ${PROJECT_SOURCE_DIR}/src/rpn-trig.cpp ${PROJECT_SOURCE_DIR}/linenoise-ng/src/ConvertUTF.cpp ${PROJECT_SOURCE_DIR}/linenoise-ng/src/linenoise.cpp diff --git a/src/program.cpp b/src/program.cpp index 2450c5a..b0ed4d7 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -199,10 +199,10 @@ program::keyword_t program::s_keywords[] = { // {cmd_keyword, "atanh", &program::rpn_atanh, "inverse hyperbolic tangent"}, // TIME AND DATE - // {cmd_undef, "", NULL, "\nTIME AND DATE"}, - // {cmd_keyword, "time", &program::rpn_time, "time in local format"}, - // {cmd_keyword, "date", &program::rpn_date, "date in local format"}, - // {cmd_keyword, "ticks", &program::rpn_ticks, "system tick in µs"}, + {cmd_undef, "", NULL, "\nTIME AND DATE"}, + {cmd_keyword, "time", &program::rpn_time, "time in local format"}, + {cmd_keyword, "date", &program::rpn_date, "date in local format"}, + {cmd_keyword, "ticks", &program::rpn_ticks, "system tick in µs"}, // end {cmd_max, "", NULL, ""}, diff --git a/src/rpn-time.cpp b/src/rpn-time.cpp index b30f503..ff984c1 100644 --- a/src/rpn-time.cpp +++ b/src/rpn-time.cpp @@ -19,10 +19,9 @@ void program::rpn_time() { ((double)tm->tm_sec) * 1000000.0 + (double)(ts.tv_nsec / 1000); // push it - number* num; - _stack->push_front(num = static_cast(new number(date))); - // division is done here because of real precision) - CHECK_MPFR(mpfr_div_d(num->_value.mpfr, num->_value.mpfr, 10000000000.0, mpreal::get_default_rnd())); + // division after push for real precision + _stack->push(new number(date)); + _stack->value(0) /= 10000000000.0; } else ERR_CONTEXT(ret_internal); } @@ -44,9 +43,9 @@ void program::rpn_date() { // push it number* num; - _stack->push_front(num = static_cast(new number(date))); - // division is done here because of real precision) - CHECK_MPFR(mpfr_div_d(num->_value.mpfr, num->_value.mpfr, 1000000.0, mpreal::get_default_rnd())); + // division after push for real precision + _stack->push(new number(date)); + _stack->value(0) /= 1000000.0; } else ERR_CONTEXT(ret_internal); } @@ -65,9 +64,7 @@ void program::rpn_ticks() { if (tm != NULL) { // date in µs date = 1000000.0 * (double)ts.tv_sec + (double)(ts.tv_nsec / 1000); - - // push it - _stack->push_front(static_cast(new number(date))); + _stack->push(new number(date)); } else ERR_CONTEXT(ret_internal); } diff --git a/test/all.md b/test/all.md index cf58cee..3ccdaf0 100644 --- a/test/all.md +++ b/test/all.md @@ -18,7 +18,7 @@ @include 080-store.md @include 090-program.md @include 100-complex.md -# @include 110-time.md +@include 110-time.md # @include 120-trig.md -# @include 120-logs.md +# @include 130-logs.md # @include 999-manual-tests.md