[Greg Ewing]
> I don't see it's because of that. Even if D(whatever)
> didn't ignore the context settings, you'd get the same
> oddity if the numbers came from somewhere else with a
> different precision.
Most users don't change context precision, and in that case there is
no operation defined in
Tim Peters wrote:
> [Raymond Hettinger]
>from decimal import getcontext, Decimal as D
>getcontext().prec = 3
>D('3.104') + D('2.104')
>>
>>Decimal("5.21")
>>
>D('3.104') + D('0.000') + D('2.104')
>>
>>Decimal("5.20")
>
> the results differ here because D(whatever)
> ignores contex
[Raymond Hettinger]
> ...
> One more change: The final "return +s" should be unindented. It should
> be at the same level as the "do with_extra_precision()". The purpose of
> the "+s" is to force the result to be rounded back to the *original*
> precision.
>
> This nuance is likely to be the ban
> +def sin(x):
> +"Return the sine of x as measured in radians."
> +do with_extra_precision():
> +i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
> +while s != lasts:
> +lasts = s
> +i += 2
> +