diff --git a/src/main/res/raw/ops.forth b/src/main/res/raw/ops.forth index 081791f..2cd0c69 100644 --- a/src/main/res/raw/ops.forth +++ b/src/main/res/raw/ops.forth @@ -99,4 +99,5 @@ : day ( -- y ) :java.util.Calendar/DAY_OF_MONTH jvm-static-var :java.util.Calendar/getInstance jvm-call-static - :get/i jvm-call-method ; \ No newline at end of file + :get/i jvm-call-method ; +: d% ( n1 n2 -- n3 ) swap dup abs >r - r> / 100 * ; diff --git a/src/test/java/com/vectron/fcl/FclTest.java b/src/test/java/com/vectron/fcl/FclTest.java index 444069f..4830fea 100644 --- a/src/test/java/com/vectron/fcl/FclTest.java +++ b/src/test/java/com/vectron/fcl/FclTest.java @@ -400,7 +400,12 @@ public class FclTest { assertEquals(10, evalPop("100 10 percent").doubleValue(), 0.001); assertEquals(100, evalPop("100 100 percent").doubleValue(), 0.001); assertEquals(130.686, evalPop("4356.2 3 percent").doubleValue(), 0.001); - assertEquals(0.16482, evalPop("1.23 13.4 percent").doubleValue(), 0.001); + assertEquals(10, evalPop("100 110 d%").doubleValue(), 0.001); + assertEquals(-10, evalPop("100 90 d%").doubleValue(), 0.001); + assertEquals(181.026, evalPop("23.4 65.76 d%").doubleValue(), 0.001); + assertEquals(-181.026, evalPop("-23.4 -65.76 d%").doubleValue(), 0.001); + assertEquals(-381.026, evalPop("23.4 -65.76 d%").doubleValue(), 0.001); + assertEquals(381.026, evalPop("-23.4 65.76 d%").doubleValue(), 0.001); } @Test