News for hackers. Stuff that matters.
Re:0.30000000000000004 by _ZeD_ on Friday November 13, 2015 @08:10AM (#10559608)
you are using Decimal "wrong". If you want it to handle exact values, you need to pass a string with the decimal interpretation

    Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from decimal import Decimal
    >>> Decimal('0.1') + Decimal('0.2') - Decimal('0.3')
    Decimal('0.0')
    >>> Decimal(0.1) + Decimal(0.2) - Decimal(0.3)
    Decimal('2.775557561565156540423631668E-17')
    >>> Decimal(0.1) == Decimal('0.1')
    False
Re:0.30000000000000004 by philh on Friday November 13, 2015 @08:17AM (#10559648)
In this case, that was deliberate. I was using it to show the exact decimal value of the floating point approximations to decimal numbers, not to do decimal arithmetic.