0

I found:

IDLE 1.2.2
>>> x = 157.73
>>> r = x * 100.
>>> int(r)
15772

Can I convert more precise?

3
Contributors
3
Replies
5
Views
9 Years
Discussion Span
Last Post by R.V.
0

The way floating point numbers are represented in many computer languages leads to roundoff errors. Take a look at this ...

q = [157.73 * 100.0]
print q                    # [15772.999999999998]
# this explains why
print int(157.73 * 100.0)  # gives 15772

For really high precision math that prepresents floating point numbers differently use the Python module decimal.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.