#78: r2d and d2r now allocate on stack

This commit is contained in:
Louis Rubet 2017-05-27 18:21:13 +02:00
parent db567f79ad
commit 24365f1c5f

View file

@ -10,14 +10,14 @@ void d2r(void)
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
mpfr_t pi;
// add pi on stack
pi();
floating_t* pi = &((number*)_stack->pop_back())->_value;
floating_t* left = &((number*)_stack->get_obj(0))->_value;
mpfr_init(pi);
CHECK_MPFR(mpfr_const_pi(pi, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_mul(left->mpfr, left->mpfr, pi, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_mul(left->mpfr, left->mpfr, pi->mpfr, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_div_si(left->mpfr, left->mpfr, 180, floating_t::s_mpfr_rnd));
mpfr_clear(pi);
}
void r2d(void)
@ -25,14 +25,14 @@ void r2d(void)
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
mpfr_t pi;
// add pi on stack
pi();
floating_t* pi = &((number*)_stack->pop_back())->_value;
floating_t* left = &((number*)_stack->get_obj(0))->_value;
mpfr_init(pi);
CHECK_MPFR(mpfr_const_pi(pi, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_div(left->mpfr, left->mpfr, pi->mpfr, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_mul_si(left->mpfr, left->mpfr, 180, floating_t::s_mpfr_rnd));
CHECK_MPFR(mpfr_div(left->mpfr, left->mpfr, pi, floating_t::s_mpfr_rnd));
mpfr_clear(pi);
}
void rpn_sin(void)