Hello Richard!

In your code:

   d(123.2345274523452345235432452345)

you are entering the number as a `float` and you are loosing the precision 
already when the code is compiled. To retain the precision all constants must 
be entered as strings. 

For illustration see this part of an interactive Python session:

>>> 123.123456789012345678901
123.12345678901235

The other issue with floating point is, that only very few numbers can be 
accurately represented. These numbers must be composed from (including 
negative) powers of two. Like this: 0.5 + 0.25 + 0.125 + 0.0625 ... 
Numbers that cant be represented accurately:

>>> 0.1
0.10000000000000001
>>> 0.3
0.29999999999999999



It would probably be a good idea, if the Python compiler would issue a warning 
when it encounters a `float` constant with excessive precision. 


Eike.
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to