Re: 2.6.1 - simple division

2009-03-14 Thread Steve Holden
farsi...@gmail.com wrote: > Thanks all, that's very helpful, sorry to waste your time with a > common question. I have tried the decimal module and will definitely > keep using it if I need to do this kind of calculation again. > > I have 1 more question that the floating point article that was li

Re: 2.6.1 - simple division

2009-03-10 Thread Tim Chase
farsi...@gmail.com wrote: 4 / 5.0 0.84 0.8 * 5 4.0 Start here: http://docs.python.org/tutorial/floatingpoint.html Play with these: >>> 4/5.0 0.84 >>> print 4/5.0 0.8 >>> print repr(4/5.0) 0.84 >>> str(4/5.0) '0.8' >>> repr(4/5.0) '0.8000

Re: 2.6.1 - simple division

2009-03-09 Thread Tim Rowe
2009/3/8 : 4 / 5.0 > 0.84 0.8 * 5 > 4.0 > > python 2.6.1 on mac. What the hell is going on here? I know this has already been answered in detail, but one thing that it's easy for those new to floating point issues to miss is that fractions that can be expressed exactly i

Re: 2.6.1 - simple division

2009-03-09 Thread Mohammad Tayseer
>>> j = .8 >>> j 0.80004 Python follows the IEEE-754 standard, which doesn't represent the numbers exactly. See http://en.wikipedia.org/wiki/IEEE_754 Mohammad Tayseer http://spellcoder.com/blogs/tayseer From: "farsi...@gmail.com" Sent: Sunday, M

Re: 2.6.1 - simple division

2009-03-08 Thread Lie Ryan
Duncan Booth wrote: farsi...@gmail.com wrote: Thanks all, that's very helpful, sorry to waste your time with a common question. I have tried the decimal module and will definitely keep using it if I need to do this kind of calculation again. Try to remember though that the decimal module simp

Re: 2.6.1 - simple division

2009-03-08 Thread farsight
Thanks duncan, thats very helpful. I'll be more careful with floating point numbers in future. -- http://mail.python.org/mailman/listinfo/python-list

Re: 2.6.1 - simple division

2009-03-08 Thread Duncan Booth
farsi...@gmail.com wrote: > Thanks all, that's very helpful, sorry to waste your time with a > common question. I have tried the decimal module and will definitely > keep using it if I need to do this kind of calculation again. Try to remember though that the decimal module simply replaces one so

Re: 2.6.1 - simple division

2009-03-08 Thread farsight
Thanks all, that's very helpful, sorry to waste your time with a common question. I have tried the decimal module and will definitely keep using it if I need to do this kind of calculation again. I have 1 more question that the floating point article that was linked didn't really answer: >>> x =

Re: 2.6.1 - simple division

2009-03-08 Thread koranthala
On Mar 8, 7:22 pm, farsi...@gmail.com wrote: > On Mar 8, 2:16 pm, farsi...@gmail.com wrote: > > > >>> 4 / 5.0 > > > 0.84>>> 0.8 * 5 > > > 4.0 > > > python 2.6.1 on mac. What the hell is going on here? > > Pure curiosity prompted me to try the following:>>> 40 / 5.0 > > 8.0 > > Stran

Re: 2.6.1 - simple division

2009-03-08 Thread Lie Ryan
farsi...@gmail.com wrote: On Mar 8, 2:16 pm, farsi...@gmail.com wrote: 4 / 5.0 0.84 This one is a common FAQ. Basically floating point is never to be trusted. This issue is quite language agnostic, however some language decided to "hide" the issue, python does not. For more

Re: 2.6.1 - simple division

2009-03-08 Thread Gabriel Genellina
En Sun, 08 Mar 2009 12:22:50 -0200, escribió: On Mar 8, 2:16 pm, farsi...@gmail.com wrote: >>> 4 / 5.0 0.84 >>> 0.8 * 5 4.0 python 2.6.1 on mac. What the hell is going on here? Pure curiosity prompted me to try the following: 40 / 5.0 8.0 Strange... See http://docs.py

Re: 2.6.1 - simple division

2009-03-08 Thread farsight
On Mar 8, 2:16 pm, farsi...@gmail.com wrote: > >>> 4 / 5.0 > > 0.84>>> 0.8 * 5 > > 4.0 > > python 2.6.1 on mac. What the hell is going on here? Pure curiosity prompted me to try the following: >>> 40 / 5.0 8.0 Strange... -- http://mail.python.org/mailman/listinfo/python-list