mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
#78: r2d and d2r now allocate on stack
This commit is contained in:
parent
db567f79ad
commit
24365f1c5f
1 changed files with 12 additions and 12 deletions
|
@ -10,14 +10,14 @@ void d2r(void)
|
|||
MIN_ARGUMENTS(1);
|
||||
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
||||
|
||||
mpfr_t pi;
|
||||
floating_t* left = &((number*)_stack->get_obj(0))->_value;
|
||||
// add pi on stack
|
||||
pi();
|
||||
|
||||
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));
|
||||
floating_t* pi = &((number*)_stack->pop_back())->_value;
|
||||
floating_t* left = &((number*)_stack->get_obj(0))->_value;
|
||||
|
||||
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;
|
||||
floating_t* left = &((number*)_stack->get_obj(0))->_value;
|
||||
// add pi on stack
|
||||
pi();
|
||||
|
||||
mpfr_init(pi);
|
||||
CHECK_MPFR(mpfr_const_pi(pi, floating_t::s_mpfr_rnd));
|
||||
floating_t* pi = &((number*)_stack->pop_back())->_value;
|
||||
floating_t* left = &((number*)_stack->get_obj(0))->_value;
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue