OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] bohemians, gentry

[ Lists Home | Date Index | Thread Index ]

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 
precision.
2. Use no datatype, and let the application figure out how to deal with the 
data.

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 
//pi-element/text().

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.

Jonathan





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS