Python pow ** results
Why the build-in operator in this example 4**(1/2) (which is a square root
operation) returns as a result 1 and not 2 as it should be expected? If is
not going to return an acceptable result it should rise an error, but
Python continues working without any crash. At least in Python 2.7.4 64
bit distribution.
It also happens with the math function pow(4,1/2) which returns 1 with no
errors.
Instead, when doing 4**(0.5) it returns as a result 2.0 which is correct,
although it mixes integers and floats without any warnings. The same
happens with pow.
Any explanation for this behaviors? Shall they be considered as bugs?
No comments:
Post a Comment