void test(); // void nop() { // nop } void good_bye() { ERR_CONTEXT(ret_good_bye); } void help() { // software name cout<=1) { ARG_MUST_BE_OF_TYPE(0, cmd_number); precision = int(((number*)_stack->pop_back())->_value); } if (precision != -1) number::s_current_precision = precision; number::s_mode = number::std; // format for mpfr_printf stringstream ss; ss << number::s_current_precision; s_mpfr_printf_format = string(MPFR_FORMAT_BEG) + ss.str() + string(MPFR_FORMAT_STD); } void fix() { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_number); int precision = int(((number*)_stack->pop_back())->_value); number::s_current_precision = int(precision); number::s_mode = number::fix; // format for mpfr_printf stringstream ss; ss << number::s_current_precision; s_mpfr_printf_format = string(MPFR_FORMAT_BEG) + ss.str() + string(MPFR_FORMAT_FIX); } void sci() { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_number); int precision = int(((number*)_stack->pop_back())->_value); number::s_current_precision = int(precision); number::s_mode = number::sci; // format for mpfr_printf stringstream ss; ss << number::s_current_precision; s_mpfr_printf_format = string(MPFR_FORMAT_BEG) + ss.str() + string(MPFR_FORMAT_SCI); } void rpn_version() { // allocate and set object unsigned int naked_entry_len = strlen(version); ostring* str = (ostring*)_stack->allocate_back(sizeof(ostring)+naked_entry_len+1, cmd_string); str->set(version, naked_entry_len); } void rpn_uname() { // allocate and set object unsigned int naked_entry_len = strlen(uname); ostring* str = (ostring*)_stack->allocate_back(sizeof(ostring)+naked_entry_len+1, cmd_string); str->set(uname, naked_entry_len); } void type() { MIN_ARGUMENTS(1); int type = _stack->back()->_type; if (type < 0 || type >= (int)cmd_max) type = (int)cmd_undef; unsigned int string_size = strlen(cmd_type_string[type]); unsigned int size = sizeof(symbol)+string_size+1; symbol* sym = (symbol*)_stack->allocate_back(size, cmd_symbol); sym->set(cmd_type_string[type], string_size, false); } void rpn_default() { program::apply_default(); } void precision() { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_number); //set MPFR float precision long prec = mpfr_get_si(((number*)_stack->pop_back())->_value.mpfr, s_mpfr_rnd); if (prec >= 0) { s_mpfr_prec = (mpfr_prec_t)prec; s_mpfr_prec_bytes = mpfr_custom_get_size(prec); } else ERR_CONTEXT(ret_out_of_range); } void round() { MIN_ARGUMENTS(1); ARG_MUST_BE_OF_TYPE(0, cmd_string); ostring* str = (ostring*)_stack->pop_back(); bool done = false; for(int rnd = (int)MPFR_DEFAULT_RND; rnd <= (int)MPFR_RNDA; rnd++) { if (string(s_mpfr_rnd_str[rnd]) == str->_value) { s_mpfr_rnd = (mpfr_rnd_t)rnd; done = true; } } if (!done) ERR_CONTEXT(ret_out_of_range); }