Re: Help with RPN programming Message #3 Posted by C.Ret on 2 Mar 2012, 3:32 a.m., in response to message #2 by Kerem Kapkin (Silicon Valley, CA)
HI, Kerem
I am in the regret to inform you that you miss a very very very little detail. So that your code is not a correct translation of the BASIC code since it don’t behave exactly the same.
If you RUN the BASIC code, you may observe the following outputs:
%---- BASIC Code ---- | ---- Screen/Display OutPut ----
LIST | RUN
10 X=1 | 1.
20 PRINT X | 2.
30 X=X+1 | 3.
40 GOTO 20 | 4.
| 5.
| ...
In comparison, this is what I get by probing out your code:
%---- HP41 Code ---- | ---- Printer OutPut ----
01 LBL 'INFTY | 0.0000 ***
02 0 | 1.0000 ***
03 LBL 01 | 2.0000 ***
04 PRX | 3.0000 ***
05 1 | 4.0000 ***
06 + | 5.0000 ***
07 GTO 01 | ...
08 END |
Has you may have note it, your code start to count from zero, whereas one is expected as starting value.
I don’t know the purpose of this counter, but other differences are that HP41 list decimals number with trailing 0 digit, where BASIC only show up integer with no fractional part draw.
O.K., I agree with you, hpnut have not specify a lot, nor has he give example. As far as we don’t know much about the purpose of his code, all this are perhaps actually unmindful.
To quickly converge to infinity, may I suggest to use a more rapid solution such as :
10 X=0 | 01 Clx
20 X=EXP(X) | 02 LBL 00
30 PRINT X | 03 e^x
40 GOTO 20 | 04 VIEW X
| 05 GTO 00
[pre]
Or, as an immediate answer
[pre]
10 PRINT 1/0 | 0 1/X
Edited: 2 Mar 2012, 3:33 a.m.
|