#132: added complex sq sqr

This commit is contained in:
Louis Rubet 2017-06-16 11:01:55 +02:00
parent 96da73ca3e
commit ee9181b7fb
2 changed files with 22 additions and 3 deletions

View file

@ -326,10 +326,19 @@ void squareroot()
void square()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
number* left = (number*)_stack->back();
CHECK_MPFR(mpfr_sqr(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
if (_stack->get_type(0) == cmd_number)
{
number* left = (number*)_stack->back();
CHECK_MPFR(mpfr_sqr(left->_value.mpfr, left->_value.mpfr, floating_t::s_mpfr_rnd));
}
else if (_stack->get_type(0) == cmd_complex)
{
dup();
mul();
}
else
ERR_CONTEXT(ret_bad_operand_type);
}
void modulo()

View file

@ -176,3 +176,13 @@ drop
(3,-4) sign
-> stack should be (0.6,-0.8)
drop
# sq (1)
(12,10) sq
-> stack should be (44,240)
drop
# sqr (1)
(12,10) sq
-> stack should be (44,240)
drop