This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Float Multiplication
Type: Stage:
Components: Documentation Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: fdrake Nosy List: effbot, fdrake, mwh, vktor
Priority: normal Keywords:

Created on 2003-10-03 04:09 by vktor, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (5)
msg18523 - (view) Author: Victor Demaria (vktor) Date: 2003-10-03 04:09
Why (1.16 * 100) is not the same than (1.16 * 10 * 10)?

I tried 1.16*100. also and it is = 115.99999999; but if I 
do 1.16*10*10 I get 116.

Thanks....

msg18524 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2003-10-03 07:48
Logged In: YES 
user_id=38376

The answer to your question can be found in the Python 
tutorial, and has nothing to do with regular expressions:

http://www.python.org/doc/tut/node14.html

Please don't use the bug tracker to ask for help in the 
future; I suggest asking on comp.lang.python (for other 
help forums, see www.python.org).
msg18525 - (view) Author: Victor Demaria (vktor) Date: 2003-10-04 02:06
Logged In: YES 
user_id=879316

I'sorry, but I don't agree...
Even 3.13 (3.1299999999999999) * 100 is 313 = like 
3.13*10*10 (3.13*100=3.13*10*10)
In this case 1.16*100 <> 1.16*10*10
Sorry again, but it is a huge difference when you do int
(1.16*100)=115  or you do int(1.16*10*10)=116
Thanks...
msg18526 - (view) Author: Victor Demaria (vktor) Date: 2003-10-04 02:06
Logged In: YES 
user_id=879316

This is not a bug.

Binary floating point cannot represent decimal fractions exactly,
so some rounding always occurs (even in Python 1.5.2).

What changed is that Python 2.0 shows more precision than before
in certain circumstances (repr() and the interactive prompt). 

You can use str() or print to get the old, rounded output: 

>>> print 0.1+0.1
0.2
>>>

Follow the link for more information:

http://www.python.org/doc/2.2.1/tut/node14.html
msg18527 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-10-06 10:07
Logged In: YES 
user_id=6656

Close again.
History
Date User Action Args
2022-04-10 16:11:35adminsetgithub: 39359
2003-10-03 04:09:06vktorcreate