Post Reply 
Decimals to improper fractions program?
06-06-2018, 09:12 PM (This post was last modified: 06-06-2018 10:15 PM by Dieter.)
Post: #7
RE: Decimals to improper fractions program?
(06-06-2018 04:33 PM)Oddballs Wrote:  I tried to use this program [NB: from another website ] on my HP35s but i get the invlaid (I) error. Does anyone have a clue whats wrong with the code?

First of all: check the code twice. Then check it once again. Compare each and every single line in your program with the listing. STO I is different from STO (I).

Looking at the code I think several GTOs and XEQs are wrong: Some lines are printed in green color, these seem to be the intended jump targets. But then F014 says XEQ F034 while XEQ F033 would make more sense. Line F025 is marked in green but then line F020 says GTO F026.

IMHO the lines with GTOs and XEQs should read like this:

F014  XEQ F033
F020  GTO F025
F024  GTO F011
F045  GTO F038

I would also replace the PSE at the end with a R/S so that you have time to read and write down the different approximations.

Please double-check the mentioned program lines as the 35s may automatically renumber jump targets while you edit the program.

After these changes the program runs just fine.

EDIT: The 15C version on that website looks more promising. Here is an adapted (and slightly tweaked) version for the 35s:

Code:
F001  LBL F
F002  ABS
F003  ENTER
F004  STO X
F005  1
F006  STO A
F007  0
F008  STO B
F009  R↓
F010  R↓
F011  IP
F012  RCLx A
F013  RCL+ B
F014  x<> A
F015  STO B
F016  x<>y
F017  FP
F018  1/x
F019  RCL A
F020  RCL÷ X
F021  FIX 0
F022  RND
F023  ALL
F024  ENTER
F025  ENTER
F026  RCL A
F027  x<>y
F028  STOP
F029  ÷
F030  RCL- X
F031  x≠0?
F032  GTO F009
F033  R↓
F034  +/-
F035  RCL A
F036  +/-
F037  x<>y
F038  RTN

[pi] XEQ F [ENTER]
3
1

[R/S]
22
7

[R/S]
333
106

[R/S]
355
113
...

As soon as the fractional approximation exactly equals the input (within 12 digits, that is) the final fraction is returned with negative signs:

[R/S]
–1146408
–364913

This way you know the program has finished and no further fractions can be expected. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Decimals to improper fractions program? - Dieter - 06-06-2018 09:12 PM



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