[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL Documentation: a number is true when...

Subject: Re: XSL Documentation: a number is true when...
From: Kai Hackemesser <kaha@xxxxxx>
Date: Wed, 25 Jul 2007 15:24:32 +0200
Re:  XSL Documentation: a number is true when...
hi, Justin,

Thanks for that very detailed answer :-)

Ciao!
Kai

Justin Johansson schrieb:
Hello Kai,

a number is true if and only if it is neither positive or negative zero
nor NaN

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 strictly-positive 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 single-precision and double-precision
numbers
respectively.

(In XPath 1.0, floating point numbers use just the IEEE double-precision
64-bit 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 floating-point, 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.