On Jan 8, 3:30 pm, Rory Campbell-Lange <[EMAIL PROTECTED]> wrote: > >>> (1.0/10.0) + (2.0/10.0) + (3.0/10.0) > 0.60000000000000009 > >>> 6.0/10.0 > 0.59999999999999998 > > Is using the decimal module the best way around this? (I'm expecting the first > sum to match the second).
Probably not. Decimal arithmetic is NOT a cure-all for floating-point arithmetic errors. >>> Decimal(1) / Decimal(3) * Decimal(3) Decimal("0.9999999999999999999999999999") >>> Decimal(2).sqrt() ** 2 Decimal("1.999999999999999999999999999") > It seem anachronistic that decimal takes strings as > input, though. How else would you distinguish Decimal('0.1') from Decimal('0.1000000000000000055511151231257827021181583404541015625')? -- http://mail.python.org/mailman/listinfo/python-list