mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
mod + div
This commit is contained in:
parent
65f43d0a4c
commit
e2eac14a57
2 changed files with 6 additions and 0 deletions
|
@ -7,6 +7,8 @@
|
|||
: percent ( n n -- n ) * 100.0 / ;
|
||||
: odd? 2 /mod drop 0 != ;
|
||||
: even? 2 /mod drop 0 = ;
|
||||
: mod /mod drop ;
|
||||
: div /mod nip ;
|
||||
( finance )
|
||||
: cin1 ( b i n -- t ) swap 100 / 1+ swap pow * ;
|
||||
: cin2 ( base interest years monthly-contribution -- .. )
|
||||
|
|
|
@ -89,6 +89,10 @@ public class FclTest {
|
|||
assertEquals(1157.625, evalPop("10.5 3 pow").doubleValue(), 0.01);
|
||||
assertEquals(asList(1l, 3l), evalGetStack("10 3 /mod"));
|
||||
assertEquals(asList(0l, 2l), evalGetStack("10 5 /mod"));
|
||||
assertEquals(1, evalPop("10 3 mod").intValue());
|
||||
assertEquals(3, evalPop("10 3 div").intValue());
|
||||
assertEquals(0, evalPop("10 5 mod").intValue());
|
||||
assertEquals(2, evalPop("10 5 div").intValue());
|
||||
assertEquals(7, evalPop("7 round").longValue());
|
||||
assertEquals(8, evalPop("7.5 round").longValue());
|
||||
assertEquals(7, evalPop("7.4 round").longValue());
|
||||
|
|
Loading…
Reference in a new issue