PEP 240 scares me

Skip Montanaro skip at pobox.com
Tue Mar 27 12:37:23 EST 2001


    Alex> AFAIK -- 1.2 would be the rational 6/5

Okay, dumb question time.  Suppose the compiler sees the string "1.2" in the
input stream.  How does it translate that into a rational number (6/5 or
12/10 or 24/20 or ...)?  Does it simply move the decimal point over
sufficiently and create the corresponding rational number that contains the
appropriate power-of-ten denominator?  What about rationals that can't be
represented correctly using decimal notation (e.g. how does one get from
0.3333 to 1/3, or is it simply approximated by 3333/10000?)

-- 
Skip Montanaro (skip at pobox.com)
(847)971-7098




More information about the Python-list mailing list