diff --git a/src/main/res/raw/ops.forth b/src/main/res/raw/ops.forth index 5ca91cb..fc54460 100644 --- a/src/main/res/raw/ops.forth +++ b/src/main/res/raw/ops.forth @@ -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 -- .. ) diff --git a/src/test/java/com/vectron/fcl/FclTest.java b/src/test/java/com/vectron/fcl/FclTest.java index fab21c6..fa4a707 100644 --- a/src/test/java/com/vectron/fcl/FclTest.java +++ b/src/test/java/com/vectron/fcl/FclTest.java @@ -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());