diff --git a/src/main/res/raw/ops.forth b/src/main/res/raw/ops.forth index fc54460..d7ae5b3 100644 --- a/src/main/res/raw/ops.forth +++ b/src/main/res/raw/ops.forth @@ -23,6 +23,8 @@ : dis ( b i n -- t ) swap 100 / 1+ swap pow / ; : tip1 ( n -- n ) 15 percent ; : tip2 ( bill split -- total tip ) / dup 115 percent swap 15 percent ; +: fire ( monthly-expense real-interest-rate -- money-needed ) 100 / swap 12 * swap / ; +: ri ( nominal-interest-rate inflation-rate -- real-interest-rate ) 100 / 1+ swap 100 / 1+ swap / 1- 100 * ; ( trigonometry ) : pi ( n -- n ) :java.lang.Math/PI jvm-static-var ; : sin ( n -- n ) :java.lang.Math/sin/d jvm-call-static ; diff --git a/src/test/java/com/vectron/fcl/FclTest.java b/src/test/java/com/vectron/fcl/FclTest.java index fa4a707..7992631 100644 --- a/src/test/java/com/vectron/fcl/FclTest.java +++ b/src/test/java/com/vectron/fcl/FclTest.java @@ -232,6 +232,8 @@ public class FclTest { assertEquals(12.006, evalPop("[ -500 50 100 150 200 250 ] irr").doubleValue(), 0.01); assertEquals(-7.431, evalPop("[ -1000 50 100 150 200 250 ] irr").doubleValue(), 0.01); assertEquals(-28.482, evalPop("-10 irr-guess ! -5000 200 230 400 202 450 irr*").doubleValue(), 0.01); + assertEquals(120000000, evalPop("400000 4 fire").doubleValue(), 0.01); + assertEquals(1.96, evalPop("4 2 ri").doubleValue(), 0.01); } private void evalDoubles(String script, List expected) {