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: Bug In Python
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jayse24, rhettinger
Priority: normal Keywords:

Created on 2005-01-04 14:53 by jayse24, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg23865 - (view) Author: JastheAce (jayse24) Date: 2005-01-04 14:53
We are trying to convert a string value of "4.02" into a 
interger value multipled by 100.

Eg: 

Int(float("4.02")*100)

I think this should return 402 but returns 401

If i replace "4.02" with "4.04, it should return 404 and it 
does

Every other number from 4.02 returns an incorrect value.

4.02
4.06
4.10
4.14

etc etc

Can someone help this is driving me mad

Cheers JastheAce
msg23866 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-01-04 19:48
Logged In: YES 
user_id=80475

This is just one of the many joys of floating point
arithmetic.  See Appendix B in the tutorial for a hint about
what is going on.

To get the results you want, run round(x,0) before applying
int().
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41396
2005-01-04 14:53:50jayse24create