| Refresh | Home EGTry.com

arithmetic and math operators


arithmetic and match operators that take 2 operands

operand1 operand2 operator result in stack comment
1 2 add 3
5 3 div 1.667
5 3 idiv 1
5 3 mod 2
1.2 2 mul 2.2
2.3 0.3 sub 2.0
2 2 atan 45 arctangent in degree
1 2 atan 26.5651
0 2 atan 0
2 3 exp 8.0 raise base 2 to exponent 3

arithmetic and match operators that take 1 operand

operand operator result in stack comment
-3 abs 3
2 neg -2
1.1 ceiling 2.0
1.1 floor 1.0
1.0 ceiling 1.0
1.0 floor 1.0
4.5 round 5.0
4.49 round 4.0
4.9 truncate 4.0
4.0 truncate 4.0
2 sqrt 1.41421
30 sin 0.5
60 sin 0.866
30 cos 0.866
60 cos 0.5
2.718 ln 0.999
10 log 1.0
100 log 2.0

rand number generator

10 srand  %set random number seed to 10
rand  = % stack: 168070
rand  = % stack: 677268843
10 srand % reset the seed
rand = %stack: 168070  the same first random number of the seed
rrand  %stack: 10. return the random number seed