math module for Decimals

alex goretoy aleksandr.goretoy at gmail.com
Sun Jan 4 11:38:11 CET 2009


No, I know there's a typo because python told me there is. If you have svn
repo locally. then cd into Lib/ and run python decimal.py

It will tell you line 683 has syntax error, please see below.

haha python-svn # python Lib/decimal.py
  File "Lib/decimal.py", line 683
    sign = 0 if _math.copysign(1.0, f) == 1.0 else 1
              ^
SyntaxError: invalid syntax


Although, It may be only because I ran it through python 2.4.3

Thanks for quick response, I wasn't expecting so quick. :)


On Sun, Jan 4, 2009 at 10:21 AM, Mark Dickinson <dickinsm at gmail.com> wrote:

> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090104/09e6e75f/attachment.html>


More information about the Python-list mailing list