mirror of
https://github.com/louisrubet/rpn
synced 2024-12-28 09:58:52 +01:00
303 lines
3.4 KiB
Text
303 lines
3.4 KiB
Text
## COMPLEX
|
|
|
|
default erase
|
|
|
|
# entry (1)
|
|
(1,2) ( 1,2) (1 ,2) (1, 2) (1,2 )
|
|
-> stack should be (1,2), (1,2), (1,2), (1,2), (1,2)
|
|
erase
|
|
|
|
# entry (2)
|
|
(1.3,2.444555
|
|
-> stack should be (1.3,2.444555)
|
|
erase
|
|
|
|
# entry (3)
|
|
(1,
|
|
-> stack should be (1,0)
|
|
erase
|
|
|
|
# entry (4)
|
|
(nan,+inf)
|
|
-> stack should be (nan,inf)
|
|
erase
|
|
|
|
# entry (5)
|
|
(0x1234,0x10.10)
|
|
-> stack should be (0x1.234p+12,0x1.01p+4)
|
|
erase
|
|
|
|
# entry (6)
|
|
(0b11,0b101)
|
|
-> stack should be (3,5)
|
|
erase
|
|
|
|
# add (1)
|
|
(1.2,2.3) (1,2) +
|
|
-> stack should be (2.2,4.3)
|
|
erase
|
|
|
|
# add (2)
|
|
(1.2,2.3) (1,2)+
|
|
-> stack should be (2.2,4.3)
|
|
erase
|
|
|
|
# add (3)
|
|
(1.2,2.3) 3+
|
|
-> stack should be (4.2,2.3)
|
|
erase
|
|
|
|
# add (4)
|
|
3 (1.2,2.3)+
|
|
-> stack should be (4.2,2.3)
|
|
erase
|
|
|
|
# sub (1)
|
|
(1.2,2.3) (2,2) -
|
|
-> stack should be (-0.8,0.3)
|
|
erase
|
|
|
|
# sub (2)
|
|
(1.2,2.3) (1,2)-
|
|
-> stack should be (0.2,0.3)
|
|
erase
|
|
|
|
# sub (3)
|
|
(1.2,2.3) 1-
|
|
-> stack should be (0.2,2.3)
|
|
erase
|
|
|
|
# sub (4)
|
|
1 (1.2,2.3) -
|
|
-> stack should be (-0.2,2.3)
|
|
erase
|
|
|
|
# mul (1)
|
|
(1,2) (3,4) *
|
|
-> stack should be (-5,10)
|
|
erase
|
|
|
|
# mul (2)
|
|
(3,4) (1,2) *
|
|
-> stack should be (-5,10)
|
|
erase
|
|
|
|
# mul (3)
|
|
(3,4) 2 *
|
|
-> stack should be (6,8)
|
|
erase
|
|
|
|
# mul (3)
|
|
2 (3,4) *
|
|
-> stack should be (6,8)
|
|
erase
|
|
|
|
# div (1)
|
|
(1,2) (3,4) /
|
|
-> stack should be (0.44,0.08)
|
|
erase
|
|
|
|
# div (2)
|
|
(1,2) 2 /
|
|
-> stack should be (0.5,1)
|
|
erase
|
|
|
|
# div (3)
|
|
2 (3,4) /
|
|
-> stack should be (0.24,-0.32)
|
|
erase
|
|
|
|
# re (1)
|
|
(1.2,3.4) re
|
|
-> stack should be 1.2
|
|
erase
|
|
|
|
# re (2)
|
|
3 re
|
|
-> error should be 3
|
|
erase
|
|
|
|
# re (3)
|
|
re
|
|
-> error should be 2
|
|
erase
|
|
|
|
# im (1)
|
|
(1.2,3.4) im
|
|
-> stack should be 3.4
|
|
erase
|
|
|
|
# im (2)
|
|
3 re
|
|
-> error should be 3
|
|
erase
|
|
|
|
# im (3)
|
|
re
|
|
-> error should be 2
|
|
erase
|
|
|
|
# chs
|
|
(3.14,6.28) chs
|
|
-> stack should be (-3.14,-6.28)
|
|
erase
|
|
|
|
# neg
|
|
(-3.14,-6.28) neg
|
|
-> stack should be (3.14,6.28)
|
|
erase
|
|
|
|
# inv (1)
|
|
(2,4) inv
|
|
-> stack should be (0.1,-0.2)
|
|
erase
|
|
|
|
# inv (2)
|
|
(0.1,-0.2) inv
|
|
-> stack should be (2,4)
|
|
erase
|
|
|
|
# abs
|
|
(3,4) abs
|
|
-> stack should be 5
|
|
erase
|
|
|
|
# sign (1)
|
|
(1,0) sign
|
|
-> stack should be (1,0)
|
|
erase
|
|
|
|
# sign (2)
|
|
(0,1) sign
|
|
-> stack should be (0,1)
|
|
erase
|
|
|
|
# sign (3)
|
|
(3,-4) sign
|
|
-> stack should be (0.6,-0.8)
|
|
erase
|
|
|
|
# sq (1)
|
|
(12,10) sq
|
|
-> stack should be (44,240)
|
|
erase
|
|
|
|
# sqr (1)
|
|
(12,10) sq
|
|
-> stack should be (44,240)
|
|
erase
|
|
|
|
# arg (1)
|
|
(1,1) arg pi 4 / ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (2)
|
|
(-1,1) arg pi 3 * 4 / ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (3)
|
|
(1,-1) arg -45 d->r ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (4)
|
|
(-1,-1) arg pi -3 * 4 / ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (5)
|
|
(1,0) arg 0 ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (6)
|
|
(0,1) arg pi 2 / ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (7)
|
|
(-1,0) arg pi ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# arg (8)
|
|
(0,-1) arg pi neg 2 / ==
|
|
-> stack should be 1
|
|
erase
|
|
|
|
# conj
|
|
(1,2) conj dup conj
|
|
-> stack should be (1,-2), (1,2)
|
|
erase
|
|
|
|
# r->c (1)
|
|
1 2 r->c
|
|
-> stack should be (1,2)
|
|
erase
|
|
|
|
# r->c (2)
|
|
1 r->c
|
|
-> error should be 2
|
|
erase
|
|
|
|
# r->c (3)
|
|
r->c
|
|
-> error should be 2
|
|
erase
|
|
|
|
# r->c (3)
|
|
'1' '2' r->c
|
|
-> error should be 3
|
|
erase
|
|
|
|
# c->r (1)
|
|
(1,2) c->r
|
|
-> stack should be 1, 2
|
|
erase
|
|
|
|
# c->r (2)
|
|
c->r
|
|
-> error should be 2
|
|
erase
|
|
|
|
# c->r (3)
|
|
'4' c->r
|
|
-> error should be 3
|
|
erase
|
|
|
|
# r->p (1)
|
|
(1,2) r->p
|
|
-> stack should be (2.2360679774997896964,1.107148717794090503)
|
|
erase
|
|
|
|
# r->p (2)
|
|
1 r->p
|
|
-> error should be 3
|
|
eras3
|
|
|
|
# r->p (3)
|
|
r->p
|
|
-> error should be 3
|
|
erase
|
|
|
|
# r->p (4)
|
|
'1' '2' r->p
|
|
-> error should be 3
|
|
erase
|
|
|
|
# ^ (1)
|
|
(1,2) 2 ^
|
|
-> stack should be (-3,4)
|
|
erase
|
|
|
|
# ^ (2)
|
|
(1,2) 4 ^
|
|
-> stack should be (-7,-24)
|
|
erase
|
|
|
|
# sqrt
|
|
(3,4) sqrt
|
|
-> stack should be (2,1)
|
|
erase
|