W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Clarification on Double/Float

From: <peiyongz@ca.ibm.com>
Date: Fri, 1 Mar 2002 18:35:53 -0500
To: xmlschema-dev@w3.org
Message-ID: <OF22863C04.56E57FDA-ON85256B6F.0079AF69@torolab.ibm.com>
Hi, there,

    I'd appreciate it very much, if anyone on the mailing list, can help to
clarify some issues we are
encountered now. The question applies to double as well.

3.2.4 float


   [Definition:]  float corresponds to the IEEE single-precision 32-bit
   floating point type [IEEE 754-1985]. The basic ˇvalue spaceˇ of float
   consists of the values m × 2^e, where m is an integer whose absolute
   value is less than 2^24, and e is an integer between -149 and 104,
   inclusive. In addition to the basic ˇvalue spaceˇ described above, the ˇ
   value spaceˇ of float also contains the following special values:
   positive and negative zero, positive and negative infinity and
   not-a-number. The ˇorder-relationˇ on float is: x < y iff y - x is
   positive. Positive zero is greater than negative zero. Not-a-number
   equals itself and is greater than all float values including positive
   infinity.

3.2.4.1 Lexical representation


   float values have a lexical representation consisting of a mantissa
   followed, optionally, by the character "E" or "e", followed by an
   exponent. The exponent ˇmustˇ be an integer. The mantissa must be a
   decimal number. The representations for exponent and mantissa must
   follow the lexical rules for integer and decimal. If the "E" or "e" and
   the following exponent are omitted, an exponent value of 0 is assumed.


   The special values positive and negative zero, positive and negative
   infinity and not-a-number have lexical representations 0, -0, INF, -INF
   and NaN, respectively.



      The issue:

       For a datatype like this:

       <simpleType name="myType">
     <restriction base="float">
          <minExclusive value="0.0"/>
          <maxInclusive value="999"/>
     </restriction>
       </simpleType>

       Shall the parser treat the "0.0" as a lexcial representation for a
normal zero,
      or for special value, positive zero?

     1.  From 3.2.4, we may conclude that we have two value spaces, one is
denoted by  m × 2^e, and the other
          which is composed of the five special values, and they are
***disjoint***.

     2. From 3.2.4.1, we know that, the value, zero, from the first value
space, could have many lexical representations,
         as long as they conform to the lexical representation of decimal.
So we have the production below.

          [+|-]? [0]+ ['.'[0]+]?

          which, unfortunately(?) contains the '0' and '-0'.

       3. So can we say,

                  A. Any string instance from the production above, except
for the '0' and '-0', are either negative zero,
                       nor positive zero, and they are **normal zero**, and
we can define the order like this:

                       negative zero < normal zero < positive zero.

                       And that is to say, we have three zeroS, negative
zero, normal zero and positive zero.

                  B. Any string instance from the production above,
                                 1. is positive zero, if there is a leading
'+' or
                                                                     no
leading sign at all,
                                 2. and is negative zero, otherwise.

                       If this is case, we have only two zeroS, negative
zero and positive zero, and we **expand** the
                       lexical representation for both negative zero and
positive zero.


Regards,

Peiyong Zhang
____________________________________________
XML Parsers Development, D2-265
IBM Toronto Laboratory , 8200 Warden, Markham

Email: peiyongz@ca.ibm.com
Phone: (905)413-4088
Fax: (905)413-4854; T/L: 778-4088
Received on Friday, 1 March 2002 18:36:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:29 GMT