[New-bugs-announce] [issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0
Devin Jeanpierre
report at bugs.python.org
Fri Jan 9 04:13:06 CET 2015
New submission from Devin Jeanpierre:
>>> 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
This is PHP-like and confusing, and maybe not justified just by standards compliance. If it is justified by standards compliance, this deserves to be spelled out in big red letters in the documentation for the decimal module, along with any other inconsistencies.
----------
components: Library (Lib)
messages: 233711
nosy: Devin Jeanpierre
priority: normal
severity: normal
status: open
title: Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23201>
_______________________________________
More information about the New-bugs-announce
mailing list