fire + ri

This commit is contained in:
zeroflag 2021-08-15 00:01:31 +02:00
parent e52108be5f
commit 88b2b00678
2 changed files with 4 additions and 0 deletions

View file

@ -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 ;

View file

@ -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<Number> expected) {