Convert decimal number to rational: Difference between revisions

m
m (→‎{{header|TI SR-56}}: Terminology)
Line 2,957:
|+ Register allocation
|-
| 0: RationalDecimal || 1: Denominator|| 2: Unused || 3: Unused || 4: Unused
|-
| 5: Unused || 6: Unused || 7: Unused || 8: Unused || 9: Unused
Line 2,964:
Annotated listing:
<syntaxhighlight lang="text">
STO 0 // RationalDecimal := User Input
0 STO 1 // Denominator := 0
*CP // RegT := 0
1 SUM 1 // Denominator += 1
RCL 1 * RCL 0 = Inv *Int // Find fractional part of RationalDecimal * Denominator
Inv *x=t 0 6 // If it is nonzero loop back to instruction 6
RCL 1 x<>t // Report denominator
Line 2,977:
'''Usage:'''
 
Enter the rationaldecimal and then press RST R/S. Once a suitable fractionrational is found, the numerator will be displayed. Press x<>t to toggle between the numerator and denominator.
 
{{in}}
Line 2,987:
After about five seconds, '''3''' will appear on the screen. Press x<>t and '''8''' will appear on the screen. The fraction is 3/8.
 
Any fraction with denominator <=100 is found in 1 minute or less. 100 fractionsdenominators are checked per minute.
 
=={{header|Vala}}==
27

edits