Kahan summation: Difference between revisions

Content added Content deleted
(New draft task and Python solution.)
 
(→‎{{header|Python}}: getcontext.)
Line 33: Line 33:
Decimal('10005.9')
Decimal('10005.9')
>>>
>>>
>>> # More info on the current Decimal context:
>>> # Lets try the simple summation with more precision for comparison
>>> getcontext()
Context(prec=6, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[InvalidOperation, DivisionByZero, Overflow])
>>>
>>>
>>> ## Lets try the simple summation with more precision for comparison
>>> getcontext().prec = 20
>>> getcontext().prec = 20
>>> (a + b) + c
>>> (a + b) + c