Oct-23-2018, 05:24 PM
I was doing some unit testing and came across something odd:
>>> -2 ** 4 -16 >>> pow(-2, 4) 16 >>> import operator >>> operator.pow(-2, 4) 16 >>> import math >>> math.pow(-2, 4) 16.0All of the documentation says that the various pow functions are equivalent to x ** y. However, the function call changes the order of operations. The negation is carried out when the number is evaluated as a parameter, instead of after the ** operator. So the pow functions are really calculating (x) ** (y), which is slightly different.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures