On Fri, Apr 4, 2014 at 1:52 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > py> from decimal import * > py> getcontext().prec = 16 > py> x = Decimal("0.7777777777787516") > py> y = Decimal("0.7777777777787518") > py> (x + y) / 2 > Decimal('0.7777777777787515') > > "Guido, why can't Python do maths???"
Well, you need to work within the system: >>> (5*x + 5*y) / 10 Decimal('0.7777777777787517') Actually, I have no idea whether that formula can be relied upon or the correctness of the above was just luck. -- https://mail.python.org/mailman/listinfo/python-list