[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Numeric type promotion

John Snelson jsnelson at sleepycat.com
Thu Oct 19 14:30:24 PDT 2006


  Numeric type promotion
Hi All,

I'm having a hard time understanding the logic behind the XQuery 
specification's numeric type promotion rules. There are three basic 
numeric types decimal, float and double. The float and double types are 
based on IEEE 754-1985 floating point numbers, and as such have certain 
deficiencies - like upper and lower limits on their values, and problems 
exactly representing common base 10 numbers.

The decimal type, on the other hand, is an arbitrary precision decimal 
number, and can accurately represent any (base 10) number of any size.

Why then do the numeric type promotion rules specify that decimal is 
converted to float or double, and not the other way around? XQuery users 
are being forced to lower the precision of their numeric calculations by 
performing type promotion this way around!

I'm sure that the extra state that is available in float and double came 
into the decision - there is no way to represent Nan, INF, -INF or -0 in 
decimal. However, mathematically -0 does not exist - it is an artifact 
of the way that the numbers are stored, and the other three are really 
only error states.

I'm sure the working group discussed these issues, I'm just wondering 
why the decisions were made.

John


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-2007 All Rights Reserved.