Decimals to fraction strings
François Pinard
pinard at iro.umontreal.ca
Wed May 17 09:54:12 EDT 2000
Mikael Olofsson <mikael at isy.liu.se> écrit:
> On 17-May-00 François Pinard wrote:
> > Not necessarily. 0.6667 is well approximated by 1:3, for example, while
> > if you force the denominator to be an exponent of 10, you will obtain a
> > fraction which is not only uglier, but less precise.
> Precise in what respect?
I mean that the fraction you get is further than 0.6667 than 1:3 is.
> Given the (possibly rounded) number 0.6667, we do not know if its origin
> is 2/3 or something else. It might very well be 6667/10000. The latter is
> definitely closer to the given number than the former, thus more precise.
Of course, if you do not tolerate any error, 6667:10000 is the only
solution. :-)
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list