x = '16473.6'
y = str(int(float(x) * 1000))
print(y)
>>>16473599
OK... obviously I did something wrong... i know that these float thing are sometimes a little bit difficult from c#... but i thought that * 1000 should work... OK wrong
Can someone tell me how to do this better?
thank you very much
Floating point numbers have always a problem with calculation as it's based on a binary approximation of numbers.
You may check Floating Point Arithmetic: Issues and Limitations
You may try using Decimal
x = '16473.6'
y = str(int(Decimal(x) * 1000))
print(y)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With