mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
fire + ri
This commit is contained in:
parent
e52108be5f
commit
88b2b00678
2 changed files with 4 additions and 0 deletions
|
@ -23,6 +23,8 @@
|
||||||
: dis ( b i n -- t ) swap 100 / 1+ swap pow / ;
|
: dis ( b i n -- t ) swap 100 / 1+ swap pow / ;
|
||||||
: tip1 ( n -- n ) 15 percent ;
|
: tip1 ( n -- n ) 15 percent ;
|
||||||
: tip2 ( bill split -- total tip ) / dup 115 percent swap 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 )
|
( trigonometry )
|
||||||
: pi ( n -- n ) :java.lang.Math/PI jvm-static-var ;
|
: pi ( n -- n ) :java.lang.Math/PI jvm-static-var ;
|
||||||
: sin ( n -- n ) :java.lang.Math/sin/d jvm-call-static ;
|
: sin ( n -- n ) :java.lang.Math/sin/d jvm-call-static ;
|
||||||
|
|
|
@ -232,6 +232,8 @@ public class FclTest {
|
||||||
assertEquals(12.006, evalPop("[ -500 50 100 150 200 250 ] irr").doubleValue(), 0.01);
|
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(-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(-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) {
|
private void evalDoubles(String script, List<Number> expected) {
|
||||||
|
|
Loading…
Reference in a new issue