50G fraction question Q> function max denominator

11092019, 01:46 PM
Post: #18




RE: 50G fraction question Q> function max denominator
(11082019 09:01 PM)Joe Horn Wrote: Albert's method automatically does that, if you use a power of 2 for D, no? (11082019 10:05 PM)Albert Chan Wrote: x' = round(x D) / D will gives you the same answer (for this case D = 2^n) OIC (Oh, I see!) So changes are in order for my last program: 1) The maximum denominator (D in your explanation) will need to be "pinned" to the greatest powerof2 ≤ the given value 2) After determining a,b,c in 'a+b/c', the GCD for b and c will be used to simplify the rational I'm building the rational manually instead of using the CAS so that the program is flagagnostic (I want it to behave the same way regardless of flag settings). I also prefer (1+1/2) to 1+1/2 when displaying negative symbolics, which is easily done by placing the negation as its final component. I find the former easier to read than the latter when on the stack. Thanks to both of you for the education! 

« Next Oldest  Next Newest »

User(s) browsing this thread: