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

Re: bohemians, gentry

Re:  bohemians
At 03:03 PM 12/4/2002 -0500, Rich Salz wrote:
>>Well, there's a problem you will encounter earlier. Float and double are 
>>restricted to 32 and 64 bits respectively:
>Only in their value space, not their lexical space.

Hmmmm....you're right, in the value space this number would be rounded, and 
it is not invalid to have more digits after the decimal point than will 
actually be used.

>My example -- with and without the type attribute -- is legit.  And shows 
>the problem.

Yes, you are right - using the *wrong* datatype can lead to loss of 
precision. There are three simple solutions here. The first two require you 
to be in control of the data:

1. Use the right datatype. It's xs:decimal, which gives you arbitrary 
2. Use no datatype, and let the application figure out how to deal with the 

The third can be used even if someone supplied the wrong datatype:

3. Ignore the specified datatype in the software that processes the data 
and access the lexical representation. For XQuery or XSLT, you would use 

Either 2 or 3 require a lot more work from the programmer. If you are in an 
environment that can use arbitrary-precision math, it's easier to use 
existing libraries and to have your parser recognize the data and deal with 
it appropriately.

So I think this basically demonstrates that (a) if you have the wrong 
datatype, and aren't paying attention, it can lull you into loss of 
precision, and (b) if you have no datatype or the wrong datatype, you can 
still get the information you want, but it may involve a lot more work. The 
work required is the same in either case, since both involve operations 
based on the lexical form.



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.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.