PyWart: Language missing maximum constant of numeric types!
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Feb 24 17:45:53 EST 2012
On Fri, 24 Feb 2012 09:23:08 -0700, Michael Torrie wrote:
> All this reminds me of the original cray supercomputers. They didn't
> use twos compliment for integers so they had two representations of zero
> (+0 and -0). Made programming a bit tricky.
While there is only one integer zero, I would like to point out that in
floating point, there are usually two zeroes, -0.0 and +0.0, and that
this is by design and a feature, not an accident or a bug.
Well-written floating point functions should keep the sign when they
underflow, e.g.:
py> 1e-200 * 1e-200
0.0
py> 1e-200 * -1e-200
-0.0
and well-written functions should honour those separate zeroes because
sometimes it makes a difference.
--
Steven
More information about the Python-list
mailing list