float problem

Tomasz Stochmal tom at peresys.co.za
Thu Mar 18 05:26:49 EST 2004


Hi


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 ?

Regards,
Tom



More information about the Python-list mailing list