tag:blogger.com,1999:blog-8699431508730375743.post7537129625622057460..comments2016-07-20T07:15:28.987-07:00Comments on The History of Python: The Problem with Integer DivisionGuido van Rossumhttp://www.blogger.com/profile/12821714508588242516noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-8699431508730375743.post-39060174843700005662014-05-09T13:14:34.044-07:002014-05-09T13:14:34.044-07:00I´m not sure if this exist, but you could add a op...I´m not sure if this exist, but you could add a optional security mechanism (like "from __future__ import safe_division_check") that fails if a the program try to divide two integers with /. So the programmer can change / for the intended // or cast.Willhttps://www.blogger.com/profile/09795080748324759564noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-66061912654801166042009-07-09T08:20:18.291-07:002009-07-09T08:20:18.291-07:00Spanish translation: here.Spanish translation: <a href="http://www.juanjoconti.com.ar/2009/07/09/la-historia-de-python-el-problema-con-la-division-entre-enteros/" rel="nofollow">here</a>.Juanjo Contihttps://www.blogger.com/profile/00311238789779841975noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-8183820724131837972009-05-26T00:26:09.012-07:002009-05-26T00:26:09.012-07:00Thank you so much for this lucid, concise and inte...Thank you so much for this lucid, concise and interesting account! As a scientist, I really appreciate that the division now returns a float.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-10396781484610674552009-05-17T17:22:00.000-07:002009-05-17T17:22:00.000-07:00Alex, this is only a display problem.
Since Pytho...Alex, this is only a display problem.<br /><br />Since Python (just like all other languages you mentioned) uses binary floating point, it cannot represent 5.1 exactly. You will notice that if you just enter 5.1 at the command line it will say the same thing. At the root is a simple rule that "rounds" binary numbers to decimal using 17 digits of precision; the binary float that closest approximates 5.1 will be converted back to decimal using that rule and you will see the unexpected outcome.<br /><br />It is being fixed in Python 3000. See http://bugs.python.org/issue1580 .Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-52635971455075888592009-05-12T02:30:00.000-07:002009-05-12T02:30:00.000-07:00I tried to make a 5.1/1 (5.1 divided by 1) in my P...I tried to make a 5.1/1 (5.1 divided by 1) in my Python 2.6/Suse Linux (in console)<br /><br />To my completely shock I got: 5.0999999999999996<br /><br />I've tested the same operation with Java, PHP and C.<br />All worked fine...<br /><br />I'm still in shock :D<br /><br />Add this to the fact that I was in the process of praising Python to my team members...Alexhttps://www.blogger.com/profile/17401806758149895813noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-28801698017327675732009-03-21T14:56:00.000-07:002009-03-21T14:56:00.000-07:00An inexact zero is a floating point zero. In ABC, ...An inexact zero is a floating point zero. In ABC, 0 and 0.000 would both give exact zeros (rational numbers); to write an inexact zero you'd have to say ~0 or 0E0.Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-30651750421113521652009-03-21T06:04:00.000-07:002009-03-21T06:04:00.000-07:00Guido, what's an 'inexact zero'? I dont understand...Guido, what's an 'inexact zero'? I dont understand the "This could be easily fixed by starting an addition with an inexact zero" sentence.<BR/><BR/>is 0 an inexact zero and 0.000 doesnt?Juanjo Contihttps://www.blogger.com/profile/00311238789779841975noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-74637121407602130492009-03-13T01:40:00.000-07:002009-03-13T01:40:00.000-07:00Guido, as someone who missed out on the earlier da...Guido, as someone who missed out on the earlier days of Python, I'm really enjoying this series. I want to thank you for doing it, and encourage you to keep it going!<BR/><BR/>- ChrisChris Learyhttps://www.blogger.com/profile/09377268785052869541noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-46098005050691154582009-03-11T14:21:00.000-07:002009-03-11T14:21:00.000-07:00My favorite example of a buggy program is: def ...My favorite example of a buggy program is:<BR/><BR/> def average(seq):<BR/> return sum(sequence) / len(sequence)<BR/><BR/>This code happily passes some tests:<BR/><BR/> assert average([1.0, 1.5, 2.0]) == 1.5<BR/> assert average([10, 20, 30]) == 20<BR/><BR/>But, it fails miserably with some inputs:<BR/><BR/> average([1,2,1,2]) --> 1rhettingerhttps://www.blogger.com/profile/12489518528561538475noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-51225303428832301872009-03-10T19:21:00.000-07:002009-03-10T19:21:00.000-07:00@Marius: maybe you'll find something if you add "A...@Marius: maybe you'll find something if you add "Arthur Siegel" to your query. And/or broaden to include edu-sig or python-list.Guido van Rossumhttps://www.blogger.com/profile/12821714508588242516noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-91938036779322524502009-03-10T18:07:00.000-07:002009-03-10T18:07:00.000-07:00Here's a testimony from the integer division wars:...Here's a testimony from the integer division wars: <A HREF="http://www.python.org/doc/humor/#neutral-testimony" REL="nofollow">neutral-testimony</A>ajaksuhttps://www.blogger.com/profile/07575045443408086084noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-61864423452840314152009-03-10T16:51:00.000-07:002009-03-10T16:51:00.000-07:00i was thinking about this issue the other day for ...i was thinking about this issue the other day for no good reason and came to the conclusion that things like // or /f or /. or however you want to do the syntax should be the way all languages work: it just seems completely crazy now to me to ever have the result implicitly depend on the input types. math doesn't work that way, at least not in my head, which of course might be a confused head. just because i'm dividing two integers and don't want to lose any fractional result parts, i have to do some weird type casting hack? how strange.<BR/><BR/>maybe i'm just missing something, like it is annoying to implement the different versions of / in languages like C. so maybe this is only doable in modern languages or whatnot.Raoul Dukehttps://www.blogger.com/profile/07354740962526930549noreply@blogger.comtag:blogger.com,1999:blog-8699431508730375743.post-43592510506947918272009-03-10T16:00:00.000-07:002009-03-10T16:00:00.000-07:00It would be very interesting to read that discussi...It would be very interesting to read that discussion about supporting mixed-mode arithmetic. My Google-fu unearths many interesting historical python-dev discussions, but not this one.Anonymousnoreply@blogger.com