[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-05-14 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23201 ___

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: A possibility would be to add (disallowed by the Decimal standard) to the exception message. That is what InvalidOperation means ;-) -- ___ Python tracker rep...@bugs.python.org

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-10 Thread Terry J. Reedy
Terry J. Reedy added the comment: Thank you Tim. A possibility would be to add (disallowed by the Decimal standard) to the exception message. -- nosy: +terry.reedy versions: -Python 3.6 ___ Python tracker rep...@bugs.python.org

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-10 Thread Stefan Krah
Stefan Krah added the comment: For the differences between the standard and IEEE 754-2008 we could link to: http://speleotrove.com/decimal/dascope.html In the long run, perhaps we should move to IEEE, because we're almost there (but that's a separate issue). --

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Tim Peters
Tim Peters added the comment: This is easy: Cowlishaw is wrong on this one, but nothing can be done about it ;-) Confusion arises because most people think of 0**0 as a value (where it certainly must be 1) while others seem to view it as some kind of shorthand for expressing a limit (as the

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: Mark Dickson wrote: I've talked to Mike Cowlishaw (the author of the specification) about this particular issue, and the spec is not likely to change on this point. I'm curious about the rationale for the decision. As I'm sure you're aware, in general

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: Does the spec have a handy list of differences to floats anywhere, or do you have to internalize the whole thing? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23201

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: this deserves to be spelled out in big red letters in the documentation for the decimal module, along with any other inconsistencies. I think you lost all sense of proportion here. The decimal module is obliged to follow the decimal spec (that is its

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread STINNER Victor
STINNER Victor added the comment: the spec is not likely to change on this point. In this case, we should just document the behaviour with a reference to the General Decimal Arithmetic Specification. -- nosy: +haypo ___ Python tracker

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: The docs already reference the spec. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23201 ___ ___

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Mark Dickinson
Mark Dickinson added the comment: This behavior seems to be required by the General Decimal Arithmetic Specification (http://speleotrove.com/decimal/daexcep.html ) Yes, exactly. The decimal module strictly follows that specification. I don't like the 0**0 - NaN result much either

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-09 Thread Stefan Krah
Stefan Krah added the comment: The behavior is already documented (power function): at least one of x or y must be nonzero The decimal docs are already so large that it is probably a bad idea to add a warning. -- ___ Python tracker

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: Yes, also, it is documented: https://docs.python.org/3/library/decimal.html#decimal.InvalidOperation Still, the status quo is bad. At the very least there should be clear documentation on how Decimal differs in behavior from floats and ints. (Other than

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Devin Jeanpierre
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

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Devin Jeanpierre
Changes by Devin Jeanpierre jeanpierr...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23201 ___ ___

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Ezio Melotti
Ezio Melotti added the comment: In the code there is this comment: # 0**0 = NaN (!), x**0 = 1 for nonzero x (including +/-Infinity) and raising the error for this specific case seems intentional. -- nosy: +ezio.melotti, facundobatista, mark.dickinson, rhettinger, skrah versions:

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Josh Rosenberg
Josh Rosenberg added the comment: Intentional, but really hard to justify from a consistency perspective. There appear to be several reasonable arguments to treat it as 1 regardless of the mathematical impurity ( https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml ), and since we

[issue23201] Decimal(0)**0 is an error, 0**0 is 1, but Decimal(0) == 0

2015-01-08 Thread Chris Rebert
Chris Rebert added the comment: This behavior seems to be required by the General Decimal Arithmetic Specification (http://speleotrove.com/decimal/daexcep.html ): The following exceptional conditions can occur: [...] Invalid operation This occurs and signals