mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
cagr, pmt, ggm
This commit is contained in:
parent
be2d76431c
commit
a1ac8378eb
3 changed files with 6 additions and 0 deletions
|
@ -50,6 +50,7 @@ var: irr-guess 0 irr-guess !
|
||||||
nil ;
|
nil ;
|
||||||
|
|
||||||
: irr* ( cashflow -- n ) >list* irr ;
|
: irr* ( cashflow -- n ) >list* irr ;
|
||||||
|
: pmt -> n 100 / -> r -> p p 1 1 1 r + n pow / - r / / ;
|
||||||
|
|
||||||
var: juggler.steps 5 juggler.steps !
|
var: juggler.steps 5 juggler.steps !
|
||||||
[ ] val: juggler.exclude
|
[ ] val: juggler.exclude
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
: 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 / ;
|
: 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 * ;
|
: ri ( nominal-interest-rate inflation-rate -- real-interest-rate ) 100 / 1+ swap 100 / 1+ swap / 1- 100 * ;
|
||||||
|
: cagr ( bv ev n -- p ) 1 swap / >r swap / r> pow 1- 100 * ;
|
||||||
|
: ggm ( cf r g -- pvg ) 100 / swap 100 / swap - / ;
|
||||||
( 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 ;
|
||||||
|
|
|
@ -237,6 +237,9 @@ public class FclTest {
|
||||||
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(120000000, evalPop("400000 4 fire").doubleValue(), 0.01);
|
||||||
assertEquals(1.96, evalPop("4 2 ri").doubleValue(), 0.01);
|
assertEquals(1.96, evalPop("4 2 ri").doubleValue(), 0.01);
|
||||||
|
assertEquals(23.8562, evalPop("10000 19000 3 cagr").doubleValue(), 0.01);
|
||||||
|
assertEquals(24389.07, evalPop("100000 7 5 pmt").doubleValue(), 0.01);
|
||||||
|
assertEquals(41.67, evalPop("2.5 11 5 ggm").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