Power-of-two fraction handling for the 41C
|
02-01-2016, 07:10 AM
(This post was last modified: 02-01-2016 07:12 AM by Dieter.)
Post: #6
|
|||
|
|||
RE: Power-of-two fraction handling for the 41C
(02-01-2016 02:06 AM)quantalume Wrote: OK, I shall then. We can compare code when I finish. Fine. Here's my version: Code: 01 LBL "D2F" Usage: Store the maximum denominator in R00. No other data registers are used. Set flag 04 if you want a fixed denominator, otherwise the fraction with the minimum denominator is returned. 64 STO 00 1,3525 XEQ"D2F" => 1 23/64 The rounded result is returned in X, the other stack registers hold the three values of the result. T: 1 Z: 23 Y: 64 X: 1,359375 Variations: The program can be easily modified to accept the max. denominator on the stack (fraction ENTER denominator XEQ"D2F") and/or return improper fractions (87/64 in this case). Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)