This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 2642 - Value space for xs:float is incorrect
Summary: Value space for xs:float is incorrect
Status: RESOLVED WORKSFORME
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Datatypes: XSD Part 2 (show other bugs)
Version: 1.0/1.1 both
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL:
Whiteboard:
Keywords: resolved
Depends on:
Blocks:
 
Reported: 2006-01-05 13:12 UTC by Michael Kay
Modified: 2006-03-09 00:13 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2006-01-05 13:12:05 UTC
The value space for xs:float is described in both 1.0 and 1.1 as

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. 

This is incorrect: it would require 33 bits to represent this value space. In
fact, single precision floating point allocates 1 bit for the sign, 8 bits for
the exponent, and 23 bits for the (unsigned) mantissa. The description should read:

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^23, and e is an integer between -149
and 104, inclusive.

Michael Kay
Comment 1 Dave Peterson 2006-01-05 17:17:22 UTC
(In reply to comment #0)

> 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. 
> 
> This is incorrect: it would require 33 bits to represent this value space. In
> fact, single precision floating point allocates 1 bit for the sign, 8 bits for
> the exponent, and 23 bits for the (unsigned) mantissa. The description should read:
> 
> 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^23, and e is an integer between -149
> and 104, inclusive.

No, the description is correct.  Because float and double do not carry variable
precision, ANSI/IEEE 754 was able to design the bit layout so that for "normal"
numbers, there is an implied 1 bit tacked onto the unsigned m.  (BTW, "mantissa"
is the wrong word; the mantissa is the fractional part of the log of m.)  For "subnormal"
numbers, the extra 1 bit is not tacked on; this allows filling in the region between
zero and the smallest "normal" number.  "Normal" in this sense means that the
number is expressible with an m and e such than  2^23 <= m  (in addition to the
general requirement of  0 < m < 2^24  and  -149 <=e <= 104 ).
Comment 2 C. M. Sperberg-McQueen 2006-03-09 00:13:12 UTC
Having examined this issue in some detail, I can confirm that 
Dave Peterson's response is accurate.  As part of a general
cleanup of the datatypes issues, I'm going to close this
marked WORKSFORME.  Michael, if you are unsatisfied with this
resolution, please let us know.  Thanks.