newb: Python Floating Point

J

johnny

When I do the following, rounding to 2 decimal places doesn't seem to
work. I should get 0.99 :

thank you.
 
R

Robert Kern

johnny said:
When I do the following, rounding to 2 decimal places doesn't seem to
work. I should get 0.99 :

0.98999999999999999

http://docs.python.org/tut/node16.html

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
D

Dan Bishop

When I do the following, rounding to 2 decimal places doesn't seem to
work. I should get 0.99 :

In binary, 0.99 is the recurring fraction 0.11 11110101110000101000
11110101110000101000 11110101110000101000 .... Thus, it can't be
exactly represented as a float.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top