Subject: Re: [xsl] XSL Documentation: a number is true when... From: Kai Hackemesser <kaha@xxxxxx> Date: Wed, 25 Jul 2007 15:24:32 +0200 
Ciao! Kai
Hello Kai,
nor NaNa number is true if and only if it is neither positive or negative zero
What is meant by positive or negative zero? From my math understandings zero is neither positive nor negative.
Your math understanding is correct. In maths though we speak of real numbers which is the union of the set of rational numbers and the set of irrational numbers (for instance, Pi). Zero, which is a rational number, is, as you say, neither positive nor negative but it is often included in the set of positive real numbers for the sake of excluding it from the set of negative real numbers. The set of strictlypositive real numbers is more precise and this set excludes zero and all negative numbers.
On digitial computers we can only approximate a real number with a limited number of bits. The XPath 1.0 standard which you are reading uses the IEEE 754 standard for representing floating point numbers. In this standard, real numbers are represented using a binary pattern consisting of 3 fields:
Sign field (1 bit), Exponent field (8 or 11 bits) and Fraction field (23 or 52 bits). This is a total of 32 or 64 bits for singleprecision and doubleprecision numbers respectively.
(In XPath 1.0, floating point numbers use just the IEEE doubleprecision 64bit format. In XPath 2.0, both single and double precision formats may be used.)
When the sign bit is zero, the number IS SAID to be greater than or equal to the real number zero. When the sign bit is one, the number IS SAID to be less than or equal to the real number zero.
The magnitude (absolute value) of the number is the value of the fraction field multiplied by 2 to the power of the value of the exponent field.
When both the exponent and fraction fields are zero the magnitude of the floating point number is zero BUT the sign bit must still be either zero or one.
Now if I may make Norman's explanation a little more precise:
and the property that zero can be signed, so that 1.0*0.0=
It's not so much a property of zero that it CAN be signed; all numbers represented by IEEE 754 standard ARE signed. It's just that in IEEE floatingpoint, there happens to be a dual representation for the real number zero, and this is reflected by the value of the sign bit.
If I drop that and say, a number is true when the value is neither zero
nor NaN, would this be correct?
You would be correct so long as you realise that by saying zero you are including the dual floating point representations of zero. However, it really does not bear much significance to most programmers as Norman says.
Cheers
Justin Johansson Australia
Current Thread 


< Previous  Index  Next > 

Re: [xsl] XSL Documentation: a numb, Justin Johansson  Thread  [xsl] Running transformations using, Michael Kay 
Re: [xsl] XSL Documentation: a numb, Justin Johansson  Date  [xsl] Using deepequal() to match s, Yves Forkl 
Month 