2015-07-23 13:22:42 +02:00
|
|
|
void plus()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(2);
|
2017-05-02 16:16:46 +02:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-05-02 16:16:46 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_add(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void minus()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(2);
|
2017-05-02 16:16:46 +02:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-05-02 16:16:46 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_sub(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void mul()
|
|
|
|
{
|
2017-05-02 16:16:46 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
|
|
|
|
|
|
|
number* right = (number*)_stack->pop_back();
|
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_mul(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void div()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
2017-05-02 16:16:46 +02:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
2017-04-18 22:53:55 +02:00
|
|
|
|
2017-05-02 16:16:46 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_div(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void neg()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(1);
|
2017-05-02 16:16:46 +02:00
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2017-04-18 22:53:55 +02:00
|
|
|
|
2017-05-02 16:16:46 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_neg(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void inv()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_si_div(left->_value.mpfr, 1L, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void purcent()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
|
|
|
|
2017-04-21 13:58:44 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_mul(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
|
|
|
CHECK_MPFR(mpfr_div_si(left->_value.mpfr, left->_value.mpfr, 100L, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void purcentCH()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
|
|
|
|
2017-04-21 13:58:44 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
|
|
|
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_mul_si(right->_value.mpfr, right->_value.mpfr, 100L, floating_t::s_mpfr_rnd));
|
|
|
|
CHECK_MPFR(mpfr_div(left->_value.mpfr, right->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void power()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
|
|
|
|
2017-04-21 13:58:44 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_pow(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void squareroot()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_sqrt(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void square()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
2015-07-23 13:22:42 +02:00
|
|
|
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_sqr(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void modulo()
|
|
|
|
{
|
2017-04-18 22:53:55 +02:00
|
|
|
MIN_ARGUMENTS(2);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
ARG_MUST_BE_OF_TYPE(1, cmd_number);
|
|
|
|
|
2017-04-21 13:58:44 +02:00
|
|
|
number* right = (number*)_stack->pop_back();
|
2017-04-18 22:53:55 +02:00
|
|
|
number* left = (number*)_stack->back();
|
|
|
|
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_fmod(left->_value.mpfr, left->_value.mpfr, right->_value.mpfr, floating_t::s_mpfr_rnd));
|
2015-07-23 13:22:42 +02:00
|
|
|
}
|
2017-05-02 17:30:34 +02:00
|
|
|
|
2017-05-22 13:48:06 +02:00
|
|
|
void rpn_abs()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
|
|
|
|
number* left = (number*)_stack->back();
|
|
|
|
|
2017-05-25 18:13:16 +02:00
|
|
|
CHECK_MPFR(mpfr_abs(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
|
2017-05-22 13:48:06 +02:00
|
|
|
}
|
|
|
|
|
2017-05-02 17:30:34 +02:00
|
|
|
void hex()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
((number*)_stack->back())->_representation = number::hex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bin()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
((number*)_stack->back())->_representation = number::bin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dec()
|
|
|
|
{
|
|
|
|
MIN_ARGUMENTS(1);
|
|
|
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
|
|
|
((number*)_stack->back())->_representation = number::dec;
|
|
|
|
}
|