float problem

Tomasz Stochmal tom at peresys.co.za
Thu Mar 18 11:26:49 CET 2004


I need to write a function that will convert a float number given as
string into long and reverse function of that, example:

'713566671863.6850' becomes 7135666718636850L
7135666718636850L becomes '713566671863.6850'

The problem is that when I call float('713566671863.6850') I get
713566671863.68506 - when rounding to 4 becomes 713566671863.6851

Output becomes 7135666718636851 but it should be 7135666718636850 

Last digit is 1 but should be 0 which is wrong !

How do I do it ?


More information about the Python-list mailing list