User Profile

Collapse

Profile Sidebar

Collapse
Mazdak
Mazdak
Last Activity: Jul 22 '08, 09:03 AM
Joined: Jul 16 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Mazdak
    replied to Decimal issues
    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...
    See more | Go to post

    Leave a comment:


  • Mazdak
    replied to Decimal issues
    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
    See more | Go to post

    Leave a comment:


  • Mazdak
    replied to Decimal issues
    Currently using Python 2.5 or 2.5.1, don't know which one =/. Do you know perhaps if there's a new version releasing anytime soon?

    :: At the code block above I suddenly started to use a variable named 'ras', thats a minor error and should be 'range' instead ::...
    See more | Go to post
    Last edited by Mazdak; Jul 17 '08, 01:31 PM. Reason: Previous posting error

    Leave a comment:


  • Mazdak
    replied to Decimal issues
    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
    ...
    See more | Go to post

    Leave a comment:


  • Mazdak
    started a topic Decimal issues

    Decimal issues

    Hey guys!

    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...
    See more | Go to post
No activity results to display
Show More
Working...