mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
#132: added complex sq sqr
This commit is contained in:
parent
96da73ca3e
commit
ee9181b7fb
2 changed files with 22 additions and 3 deletions
|
@ -326,10 +326,19 @@ void squareroot()
|
|||
void square()
|
||||
{
|
||||
MIN_ARGUMENTS(1);
|
||||
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
||||
|
||||
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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue