Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83396
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.031 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'implements': 0.09; 'cc:addr:python-list': 0.11; 'bug': 0.12; 'jan': 0.12; 'operands': 0.16; 'url:decimal': 0.16; 'wrote:': 0.18; 'module': 0.19; 'differ': 0.19; 'thu,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'specifies': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; 'raise': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '"",': 0.31; '>>>>': 0.31; 'decimal': 0.31; 'occurs': 0.31; 'subject:numbers': 0.31; 'subject:other': 0.31; 'file': 0.32; 'skip:c 30': 0.32; '(most': 0.33; 'noticed': 0.34; 'skip:d 20': 0.34; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'recent': 0.39; 'to:addr:gmail.com': 0.65; 'invalid': 0.68; 'power': 0.76; 'behavior': 0.77; '2015': 0.84; 'sender:addr:chris': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=ODIeVGYmaItciEmxD1V1nx7eGxT3Aq3QeOwjFiO/0Eo=; b=OyBEwmtJQ1zoGLh+Lsbr/IKRhD5tOEJhT9ZgNhVY5+iZsGq1smeVQ9xkkwh+S32UAp gl0bZq1h7+CiXpe2sqbI4PawmX28oE07LdrtO5z02fmtltCkZ71L6Xbj4XNpGVAKWh0T /lpGLlSvQBurbcqHIOA9x6LyIMjgRoC4+7r1o= |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ODIeVGYmaItciEmxD1V1nx7eGxT3Aq3QeOwjFiO/0Eo=; b=W1G8/kVeVd0K4HsPEzorTWGQRQgoghOJj8W6IDD21D2+FjimhpQYARg+1wn8h3llav PfxMHnqFVR+aVnkF/D0Q7MlDlUgR49A4eiHNMJ3fmlFq5z3Hfx1lWb0paRoleFA+vvPK SjeT+aFBxGtfvk79u0Up3C9JFqqWPu8PUGr1D6dcnbu1BBzQS4VumnfjUtW968SWo3Cb zT4ps7eWuR4SSoI1K0t901QsbuIv7pArdmOMrySIun9OkoAai6F13v2BET39VqwpDjxC fb99o3BxMvUREEXFmOJyYepWUqI0GEdsHVGV3wDkGVcV3DXul4XBtrmXFMNgJESZDU8D eeTA== |
| X-Gm-Message-State | ALoCoQnFaLZSQcNpclwVvElKZM83BVlT2vEx0vvV6FNwQh1Zsme051wCz7Lc0TUT/YIQbRR5qCsP |
| MIME-Version | 1.0 |
| X-Received | by 10.42.44.197 with SMTP id c5mr11156272icf.35.1420772016965; Thu, 08 Jan 2015 18:53:36 -0800 (PST) |
| Sender | chris@rebertia.com |
| In-Reply-To | <CABicbJK-5izGtet8BsS1Yqx+6AHMX7gLU4zYjjt5jULJXNVipA@mail.gmail.com> |
| References | <CABicbJK-5izGtet8BsS1Yqx+6AHMX7gLU4zYjjt5jULJXNVipA@mail.gmail.com> |
| Date | Thu, 8 Jan 2015 18:53:36 -0800 |
| X-Google-Sender-Auth | v8rsXf3PwWwMlvuBsMKD5SiybyA |
| Subject | Re: Decimals and other numbers |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "comp.lang.python" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17500.1420772019.18130.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1420772019 news.xs4all.nl 2878 [2001:888:2000:d::a6]:48530 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83396 |
Show key headers only | View raw
On Thu, Jan 8, 2015 at 6:33 PM, Devin Jeanpierre <jeanpierreda@gmail.com> wrote:
> I noticed some very PHP-ish behavior today:
>
>>>> import decimal
>>>> x = 0
>>>> y = float(x)
>>>> z = decimal.Decimal(x)
>>>> x == y == z == x
> True
>>>> x ** x
> 1
>>>> y**y
> 1.0
>>>> z**z
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.7/decimal.py", line 2216, in __pow__
> return context._raise_error(InvalidOperation, '0 ** 0')
> File "/usr/lib/python2.7/decimal.py", line 3872, in _raise_error
> raise error(explanation)
> decimal.InvalidOperation: 0 ** 0
>
> I'd file a bug report but I'm anticipating some rational (heh)
> explanation. Any ideas?
The `decimal` std lib module implements the General Decimal Arithmetic
Specification (http://speleotrove.com/decimal/decarith.html ).
In the "Exceptional conditions" section
(http://speleotrove.com/decimal/daexcep.html ), it specifies the
following:
Invalid operation
This occurs and signals invalid-operation if:
[...]
* both operands of the power operation are zero
No idea why it chose to differ from IEEE-754.
Cheers,
Chris
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Decimals and other numbers Chris Rebert <clp2@rebertia.com> - 2015-01-08 18:53 -0800
csiph-web