Steven D'Aprano wrote: > 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.
So does the fact that the "-0.0" and "+0.0" strings can be converted by C compilator to floats and stored with different bit patterns means that they can behave much different in computation and comparison than real numbers written in an expression on a piece of paper? Rather not. Floating point is only a (very useful) finite precision model (there are others) of real (rational) numbers and these differences are implementation details for me. And as far as the division by signed floating point zero and similar operations in IEEE 754 are concerned, again, this is only a model in which 0.0 means a value that is either equal to real zero or greater, but too small to be distinguished from zero using finite amount of bits (similarly -0.0), so the expressions like 1.0/-0.0 -> -1.#INF 1.0/0.0 -> 1.#INF have some justification, although being meaningless in ordinary arithmetic. To be not so off-topic, I also expect from Python's integer, float and Decimal computer formats to behave as much similar to their equivalents known from math lessons as possible, which in particular means '==' equality of -0 and 0, -0.0 and 0.0, and Decimal("-0") and Decimal("0"), no matter what. > 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. As far as math stuff is concerned I will make it short. You can't deny that there is still unique additive identity in an additive group. I also wouldn't mix symbols of physics states or others with ordinary math expressions as this is only a matter of notation of some concept (feel free to use any symbol you want). Thanks for stimulating my neural cells, cheers, fw -- http://mail.python.org/mailman/listinfo/python-list