math module for Decimals

Mark Dickinson dickinsm at gmail.com
Sun Jan 4 11:21:34 CET 2009


On Jan 4, 9:52 am, "alex goretoy" <aleksandr.gore... at gmail.com> wrote:
> Also, another reason why I'm posting to this thread. I noticed some
> error/typo in line 683 of decimal.py located on public svn repo. This is
> what is looks like.
>
>         sign = 0 if _math.copysign(1.0, f) == 1.0 else 1

This line looks okay to me; can you say why you think there's a typo
here?

If it's the 'sign = 0' part that's bothering you, that's just
a peculiarity of Decimal: the stored sign value is 0 for
positive numbers, 1 for negative numbers, which I agree
is a little counterintuitive.  (Think of the sign
as analogous to the sign *bit* in an IEEE 754 floating-point
number.)

Mark



More information about the Python-list mailing list