On Sat, 24 Jun 2006 05:36:17 -0700, Filip Wasilewski wrote: > Steven D'Aprano wrote: >> On Fri, 23 Jun 2006 02:17:39 -0700, Filip Wasilewski wrote: >> >> > [EMAIL PROTECTED] wrote: >> > >> >> Logically, I should be able to enter x[-2:-0] to get the last and next to >> >> last characters. However, since Python doesn't distinguish between >> >> positive and negative zero, this doesn't work. Instead, I have to enter >> >> x[-2:]. >> > >> > Hooray! Logically there is no such thing as positive or negative zero, >> > or did I miss something in the primary? >> >> No, not in the primary, or even in the secondary, but possibly in the >> tertiary. >> >> For many purposes, it doesn't make sense to distinguish +0 from -0. But >> for other purposes, it does. > > I believe you will agree that this is mostly a matter of notation of > some fact rather than really trying to sign zero.
No. In floating point, +0 *really is* different from -0 -- the two floats have different bit patterns. Floating point libraries must be specifically programmed to ignore that difference, making zero treated differently than other floats. That's -- usually -- a good thing. In mathematics, well, maybe... certainly in the Real number system, there is no difference, and +0 and -0 are just two ways of writing the same thing. In the hyperreals, +0 and -0 are the same, but there are infinitesimals which are different, and signed. I don't know enough about the surreals to comment. In matrix maths, there are an infinite number of different matrices where all the elements are zero -- they are all distinct, different, zeroes. And in "the real world", all numbers are an abstraction anyway, so I'm not too worried about correspondence to reality. If mathematicians find a use for distinguishing +0 from -0 (as the statistical physicists have done) they will treat them as "really" different. If they don't, they won't. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list