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
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
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
>>> 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
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
Thanks duncan, thats very helpful. I'll be more careful with floating
point numbers in future.
--
http://mail.python.org/mailman/listinfo/python-list
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
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 =
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
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
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
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
12 matches
Mail list logo