The Decimal module returns the whole instance instead of extracting the value I want. I spoke with some proffessionals and they gave a bit of a lecture. All programming languages have this float-issue, it's just that they present it better than Python. Now if you type:
Code:
>>> a = 51.1 + 2.1
>>> print a
53.2
Dunno if this is correct but Python "hides" away...
A quicky note for those that totally lost faith in the float datatype: Python is still able to represent decimals in the base of 2, for example 51.5.. 51,25 and 51.125.
Hopefully we'll see a future Python with the same easy goin' way and no float issues. Huzzah for that! =D
Oh yeah, that dirty trick really sounds good. The problem is that Python really doesnt like rounding when you have the floating point issue:
Code:
from decimal import *
>>> range = Decimal("-65.0")
>>> range = range + 0.1
>>> range
-64.90000000000006
>>>str(range)
'-64.9'
>>> float(ras)
-64.900000000000006
I recently bumped into a problem when I was calculating with simple additions. I had declared a variable eariler that we'll name "range" here.
In a loop range was added "+1". If a certain value was reached ( another variable ) then range was added with "+0.1" instead. Now this is where the issue occured.
The problem was identified as a "floating point issue" through several...
Leave a comment: