a := 4/3, b := 7/3 MsgBox % Fract(a+b) " " Fract(-1000.3333333) " " Fract(-5/6 + 3/8) Fract( a, maxDenominator = 128, maxError = 0.00001 ) { Loop % maxDenominator { d:= A_Index, n:= Round(a*d) If Abs(n/d - a) <= maxError return n "/" d } return a }
rational numbers, not decimal approximations
Started by
Tilter_of_Windmills
, Jun 11 2012 02:54 PM
15 replies to this topic
Here is another ( better and simpler ) solution. The same idea different approach.
#16
-
Posted 13 June 2012 - 05:05 AM