F
farsight
4 / 5.0
0.8000000000000000044.0
python 2.6.1 on mac. What the hell is going on here?
0.8000000000000000044.0
python 2.6.1 on mac. What the hell is going on here?
0.800000000000000004>>> 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:
8.0
Strange...
Pure curiosity prompted me to try the following:
8.0
Strange...
Pure curiosity prompted me to try the following:>>> 40 / 5.0
8.0
Strange...
Duncan said:Try to remember though that the decimal module simply replaces one source
of inaccuracies with another one:
1.0
Sometimes you want floating point, sometimes you want Decimal. You need to
understand the advantages and drawbacks of each in order to make an
informed choice.
You should certainly expect that the final result may be a little bit away
from the 'exact' result but rounding errors can work in your favour just as
well as they work against.
2009/3/8 said:4.0
python 2.6.1 on mac. What the hell is going on here?
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:
4.0
Shouldn't I be expecting something like 4.0000000000002 ?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.