Issue40981
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.
Created on 2020-06-15 05:36 by rskiredj@hotmail.com, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (17) | |||
---|---|---|---|
msg371519 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 05:36 | |
I noticed i big problem making a simple increment of .1 in python 3.7 using while the result is wrong i=0 while i < 1.2: i += 0.1 print(i) result == RESTART: C:/Users/icosf/AppData/Local/Programs/Python/Python37-32/bb.py == 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999 1.0999999999999999 1.2 what the heck is going on, can someone explain to me |
|||
msg371521 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2020-06-15 05:53 | |
https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate This is not Python 3.7 specific issue, and is not even Python issue. It is how floating-point numbers work. |
|||
msg371522 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:03 | |
problem actually more serious, it is here print(0.7+0.1) , which gives .799999999999 same thing when adding the .1 increment to 4.8 , 5.1 etc ... I am not sure of the pattern but it is acting up with some numbers who will fix this , this is serious I wouldn't trust a language behaving crazy like this the problem is not there in 2.7 why you closed the ticket , who are you |
|||
msg371523 - (view) | Author: SilentGhost (SilentGhost) * | Date: 2020-06-15 06:13 | |
This isn't a problem, this is how floating number implemented in Python and many other languages. Please read the linked detailed explanation and do not re-open the ticket. |
|||
msg371524 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:15 | |
so anybody can close a ticket ? anybody can say their point of view and close a ticket, is that how it goes? this is not serious who is managing this ? is this how we can trust a programming language? it sounds like we are dealing with irresponsible kids here please don't close this ticket until we understand that there is actually this problem in 3.7 and that the problem is fixed |
|||
msg371525 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:27 | |
Christian Heimes why did you close it |
|||
msg371526 - (view) | Author: Christian Heimes (christian.heimes) * | Date: 2020-06-15 06:29 | |
Multiple people already told you that it is not a bug. It's how floating point standard IEEE 754 works. |
|||
msg371527 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:31 | |
Christian Heimes you haven't tried it on 2.7 did you ? |
|||
msg371528 - (view) | Author: Christian Heimes (christian.heimes) * | Date: 2020-06-15 06:40 | |
Python's float are IEE 754 floats for over 25 years and since Python 1.x, maybe earlier. IIRC standard is from 1985. It's how CPUs have dealt with floats for over 35 years. By the way it's is incredible rude to keep re-opening a bug and responding on a closed bug. Do not reopen the bug again. |
|||
msg371529 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:45 | |
what is rude is to talk to me in an autoritative way like you do you haven't even checked what I said , I said it working in Python 2.7 and it is not in 3.7 and you want to just read me an article. ________________________________ From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Christian Heimes <report@bugs.python.org> Sent: Monday, June 15, 2020 2:40 AM To: rskiredj@hotmail.com <rskiredj@hotmail.com> Subject: [issue40981] increment is wrong in 3.7 but not in 2.7 Christian Heimes <lists@cheimes.de> added the comment: Python's float are IEE 754 floats for over 25 years and since Python 1.x, maybe earlier. IIRC standard is from 1985. It's how CPUs have dealt with floats for over 35 years. By the way it's is incredible rude to keep re-opening a bug and responding on a closed bug. Do not reopen the bug again. ---------- status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40981> _______________________________________ |
|||
msg371530 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:47 | |
you can at least try it and see for yourself that what I am saying is actually true but never mind I will keep on opening tickets until someone tries it on 2.7 and see what I am talking about ________________________________ From: Redwane Freedom Is-to-Be-With-God <rskiredj@hotmail.com> Sent: Monday, June 15, 2020 2:45 AM To: Python tracker <report@bugs.python.org> Subject: Re: [issue40981] increment is wrong in 3.7 but not in 2.7 what is rude is to talk to me in an autoritative way like you do you haven't even checked what I said , I said it working in Python 2.7 and it is not in 3.7 and you want to just read me an article. ________________________________ From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Christian Heimes <report@bugs.python.org> Sent: Monday, June 15, 2020 2:40 AM To: rskiredj@hotmail.com <rskiredj@hotmail.com> Subject: [issue40981] increment is wrong in 3.7 but not in 2.7 Christian Heimes <lists@cheimes.de> added the comment: Python's float are IEE 754 floats for over 25 years and since Python 1.x, maybe earlier. IIRC standard is from 1985. It's how CPUs have dealt with floats for over 35 years. By the way it's is incredible rude to keep re-opening a bug and responding on a closed bug. Do not reopen the bug again. ---------- status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40981> _______________________________________ |
|||
msg371531 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 06:48 | |
you can at least try it and see for yourself that what I am saying is actually true but never mind I will keep on opening tickets until someone tries it on 2.7 and see what I am talking about ________________________________ From: Redwane Freedom Is-to-Be-With-God <rskiredj@hotmail.com> Sent: Monday, June 15, 2020 2:45 AM To: Python tracker <report@bugs.python.org> Subject: Re: [issue40981] increment is wrong in 3.7 but not in 2.7 what is rude is to talk to me in an autoritative way like you do you haven't even checked what I said , I said it working in Python 2.7 and it is not in 3.7 and you want to just read me an article. ________________________________ From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Christian Heimes <report@bugs.python.org> Sent: Monday, June 15, 2020 2:40 AM To: rskiredj@hotmail.com <rskiredj@hotmail.com> Subject: [issue40981] increment is wrong in 3.7 but not in 2.7 Christian Heimes <lists@cheimes.de> added the comment: Python's float are IEE 754 floats for over 25 years and since Python 1.x, maybe earlier. IIRC standard is from 1985. It's how CPUs have dealt with floats for over 35 years. By the way it's is incredible rude to keep re-opening a bug and responding on a closed bug. Do not reopen the bug again. ---------- status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40981> _______________________________________ |
|||
msg371532 - (view) | Author: Steven D'Aprano (steven.daprano) * | Date: 2020-06-15 06:51 | |
> I wouldn't trust a language behaving crazy like this I guess then you won't trust C, Java, C++, Swift, Javascript, Ruby, Cobol, Fortran, and pretty much every programming language in existence. The only ones that escape this are ones that don't have floating point numbers at all. > you haven't tried it on 2.7 did you ? We know how Python 2.7 works. Some of us have been using Python for 25 years, since version 1.5 or older. Do you think you are the first person to have noticed this? There are hundreds of thousands of Python programmers, believe me you're not the first, or even the ten-thousandth person to have noticed. Python 2.7 rounds off the default display of floats to make them look "pretty" instead of displaying their actual value. Try this in 2.7 and see what happens: i=0 while i < 1.2: i += 0.1 print "default:", i, "actual: %.24f" % i The calculations are *precisely* the same, only the display is different. Honestly Mike, this is not a Python issue, it is universal to all languages with fixed-size floating point numbers. This is not a bug, it is how numeric computing works *everywhere*. People write peer reviewed scientific papers about this: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html If you want to educate yourself on the issue, rather than just rant about not trusting the language and abuse people who have been using the language for decades, you could do a lot worse than to start here: https://randomascii.wordpress.com/2012/05/20/thats-not-normalthe-performance-of-odd-floats/ https://randomascii.wordpress.com/2012/04/05/floating-point-complexities/ and take careful note that the author talks about C, probably the most common, fundamental and trusted programming language in the world. (Also remember that when Bruce Dawson talks about floats in C, they are half the precision of Python floats, which are C doubles.) The bottom line is that floats are not the infinitely precise exact mathematical numbers we learn about in school, they are more like the numbers you get on a calculator. |
|||
msg371533 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 07:40 | |
I appreciate taking the time to explain , I just wished the other guys did that instead of just closing the ticket on my face. I wished at least they suggested me to use round() without any aggravations but thanks anyway ________________________________ From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Steven D'Aprano <report@bugs.python.org> Sent: Monday, June 15, 2020 2:51 AM To: rskiredj@hotmail.com <rskiredj@hotmail.com> Subject: [issue40981] increment is wrong in 3.7 but not in 2.7 Steven D'Aprano <steve+python@pearwood.info> added the comment: > I wouldn't trust a language behaving crazy like this I guess then you won't trust C, Java, C++, Swift, Javascript, Ruby, Cobol, Fortran, and pretty much every programming language in existence. The only ones that escape this are ones that don't have floating point numbers at all. > you haven't tried it on 2.7 did you ? We know how Python 2.7 works. Some of us have been using Python for 25 years, since version 1.5 or older. Do you think you are the first person to have noticed this? There are hundreds of thousands of Python programmers, believe me you're not the first, or even the ten-thousandth person to have noticed. Python 2.7 rounds off the default display of floats to make them look "pretty" instead of displaying their actual value. Try this in 2.7 and see what happens: i=0 while i < 1.2: i += 0.1 print "default:", i, "actual: %.24f" % i The calculations are *precisely* the same, only the display is different. Honestly Mike, this is not a Python issue, it is universal to all languages with fixed-size floating point numbers. This is not a bug, it is how numeric computing works *everywhere*. People write peer reviewed scientific papers about this: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html If you want to educate yourself on the issue, rather than just rant about not trusting the language and abuse people who have been using the language for decades, you could do a lot worse than to start here: https://randomascii.wordpress.com/2012/05/20/thats-not-normalthe-performance-of-odd-floats/ https://randomascii.wordpress.com/2012/04/05/floating-point-complexities/ and take careful note that the author talks about C, probably the most common, fundamental and trusted programming language in the world. (Also remember that when Bruce Dawson talks about floats in C, they are half the precision of Python floats, which are C doubles.) The bottom line is that floats are not the infinitely precise exact mathematical numbers we learn about in school, they are more like the numbers you get on a calculator. ---------- nosy: +steven.daprano _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40981> _______________________________________ |
|||
msg371564 - (view) | Author: Terry J. Reedy (terry.reedy) * | Date: 2020-06-15 15:46 | |
Mike, when you respond by email, delete the text you are responding to. Your email is posted below the already posted text and the quote is useless noise that makes it harder to see what you wrote. Newcomers to Python who think they have seen a bug should best post to python-list or similar forums asking "Is this a bug? If not, please explain.". |
|||
msg371591 - (view) | Author: mike stern (rskiredj@hotmail.com) | Date: 2020-06-15 19:37 | |
sorry but I don't see the option to delete ________________________________ From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Terry J. Reedy <report@bugs.python.org> Sent: Monday, June 15, 2020 11:46 AM To: rskiredj@hotmail.com <rskiredj@hotmail.com> Subject: [issue40981] increment is wrong in 3.7 but not in 2.7 Terry J. Reedy <tjreedy@udel.edu> added the comment: Mike, when you respond by email, delete the text you are responding to. Your email is posted below the already posted text and the quote is useless noise that makes it harder to see what you wrote. Newcomers to Python who think they have seen a bug should best post to python-list or similar forums asking "Is this a bug? If not, please explain.". ---------- nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue40981> _______________________________________ |
|||
msg371608 - (view) | Author: Steven D'Aprano (steven.daprano) * | Date: 2020-06-16 00:08 | |
On Mon, Jun 15, 2020 at 07:37:16PM +0000, mike stern wrote: > sorry but I don't see the option to delete Your keyboard has a Delete key and a Backspace key. Select the quoted text in your email client and press one or the other. If you can't see the quoted text in Hotmail, them I'm afraid you will have to do some homework of your own and find out how to do it in Hotmail. Possibly there is an option to reply *without* quoting the message you are replying to? |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:32 | admin | set | github: 85153 |
2020-06-16 00:08:42 | steven.daprano | set | messages: + msg371608 |
2020-06-15 19:37:16 | rskiredj@hotmail.com | set | messages: + msg371591 |
2020-06-15 15:46:19 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg371564 |
2020-06-15 07:40:37 | rskiredj@hotmail.com | set | messages: + msg371533 |
2020-06-15 06:51:20 | steven.daprano | set | nosy:
+ steven.daprano messages: + msg371532 |
2020-06-15 06:48:21 | rskiredj@hotmail.com | set | messages: + msg371531 |
2020-06-15 06:47:48 | rskiredj@hotmail.com | set | messages: + msg371530 |
2020-06-15 06:45:27 | rskiredj@hotmail.com | set | messages: + msg371529 |
2020-06-15 06:40:32 | christian.heimes | set | status: open -> closed messages: + msg371528 |
2020-06-15 06:31:54 | rskiredj@hotmail.com | set | status: closed -> open messages: + msg371527 |
2020-06-15 06:29:56 | christian.heimes | set | status: open -> closed messages: + msg371526 nosy: + christian.heimes |
2020-06-15 06:28:52 | rskiredj@hotmail.com | set | nosy:
- terry.reedy, serhiy.storchaka title: increment is wrong in 3.7 -> increment is wrong in 3.7 but not in 2.7 |
2020-06-15 06:27:59 | rskiredj@hotmail.com | set | status: closed -> open messages: + msg371525 |
2020-06-15 06:25:45 | christian.heimes | set | status: open -> closed |
2020-06-15 06:15:30 | rskiredj@hotmail.com | set | status: closed -> open nosy: - SilentGhost messages: + msg371524 |
2020-06-15 06:13:00 | SilentGhost | set | status: open -> closed messages: + msg371523 nosy: + SilentGhost |
2020-06-15 06:03:07 | rskiredj@hotmail.com | set | status: closed -> open messages: + msg371522 |
2020-06-15 05:53:58 | serhiy.storchaka | set | status: open -> closed nosy: + serhiy.storchaka messages: + msg371521 resolution: not a bug stage: resolved |
2020-06-15 05:36:56 | rskiredj@hotmail.com | create |