Post Reply 
Store and reuse intermediate variable
12-12-2022, 03:16 PM
Post: #9
RE: Store and reuse intermediate variable
Hi all.
I just make a small variant to my simple program, in order to be general, here the code:
Code:

<<"Ins C t A n " {
":C:
:t:
:A:
:n:" {1 0} V} INPUT OBJ-> 0 -> C t A n R
<<'C* (t/100/n)/(1-(1+t/100/n)^(-n*A))' -> NUM 'R' STO R
>> 
>>
Now I can manage properly local variables, but with this code, where n (number of periods of mortgage) is a variable and not a fixed value.
In this version of program, I've the problem that, even if I wrote -> NUM, I can see an algebraic result (the formula) and not the results number.
I don't understood why, so after some tests I modified in this version;
Code:

<<"Ins C t A n " {
":C:
:t:
:A:
:n:" {1 0} V} INPUT OBJ-> 0 0 -> C t A n R P
<<'n*A' -> NUM 'P' STO P 'C* (t/100/n)/(1-(1+t/100/n)^(-P))' -> NUM 'R' STO R
>> 
>>
In this way, program is ok. In the stack, at the end, I can see number of period, morgage installment, and total debt.
Why if in the exponent I keep 'n*A' indeed P (=n*A) doesn't work?
Actually I don't need to display also "P" during calculation, in other programs, if I have to calculate intermediate values, is not important see the value on the stack.
Thanks in advance.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Store and reuse intermediate variable - oierpa - 12-12-2022 03:16 PM



User(s) browsing this thread: 1 Guest(s)