Decimals and other numbers

Ben Finney ben+python at benfinney.id.au
Fri Jan 9 03:43:04 CET 2015


Devin Jeanpierre <jeanpierreda at gmail.com> writes:

> decimal.InvalidOperation: 0 ** 0
>
> I'd file a bug report but I'm anticipating some rational (heh)
> explanation. Any ideas?

First note that it's explicitly documented as an invalid operation
<URL:file:///usr/share/doc/python3-doc/html/library/decimal.html#decimal.InvalidOperation>.
So someone has at least thought about it and deliberately decided it
should be so.

Why that should be, I don't know; I think the correct behaviour is for
‘0 ** 0 == 1’. But perhaps someone else has a better explanation for why
Decimal should behave differently from ‘int’ and ‘float’ here.

-- 
 \      “I bought a self learning record to learn Spanish. I turned it |
  `\        on and went to sleep; the record got stuck. The next day I |
_o__)                   could only stutter in Spanish.” —Steven Wright |
Ben Finney




More information about the Python-list mailing list