[xsd-users] xs:double truncation

Boris Kolpackov boris at codesynthesis.com
Fri Jun 20 13:38:28 EDT 2008


Hi Aaron,

Boris Kolpackov <boris at codesynthesis.com> writes:

> You can achieve the same behavior as in 2.x.x by compiling your code
> with XSD_FP_ALL_DIGITS macro defined. 

Actually, this is not exactly true. In 2.x.x we mapped xsd:double to
double and xsd:decimal to long double. Unfortunately, some compilers
don't like the long double type and issue all kinds of warnings.
So in 3.x.x we have changed the mapping: now both xsd:double and
xsd:decimal are mapped to double. One negative consequence of this
change is that because xsd:decimal cannot be in scientific notation
and both xsd:double and xsd:decimal are mapped to double, xsd:double
is always serialized in fixed notation. I think this is the reason
why you get 0. One solution (illustrated in the custom-double example
I mentioned earlier) is to re-map xsd:decimal back to long double and
use scientific notation for xsd:double.

Boris




More information about the xsd-users mailing list