[xsd-users] no reaction on XSD_CXX_TREE_DECIMAL_PRECISION

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Fri Sep 12 12:15:03 EDT 2008


I'm also going to need to use these macros.  I am currently getting these results w/3.1:

Input: 25.99000000
Output:  25.989999999999998

I am hoping to get this with 3.2, assuming I use the macro's to limit to a precision of 8:

Input: 25.99000000
Output:  25.99000000

One thing, however, that I don't like about the macros is that they apply globally.  I would really like to be able to specify the precision dynamically based on the input precision I read in.  I.e., if I read in 25.99 as a string, and note that there are 2 digits of precision, I would want to somehow specify that detail for the XML double that I create from it.

Also, I recall seeing an earlier posting where a small float, say 0.357E-30 is truncated to 0 on output.  I think the issue here is the way precision is defined.  I would prefer something more akin to the engineering definition of significant digits.  I.e. 0.357E-30 has 3 significant digits.  If I request the precision to be 2 digits, then I'd expect 0.36E-30 on output.

Ray

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Friday, September 12, 2008 4:33 AM
To: Gennady Khokhorin
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] no reaction on XSD_CXX_TREE_DECIMAL_PRECISION

Hi Gennady,

Gennady Khokhorin <gok at aerometric-ak.com> writes:

> input: 65.043000
> output: 65.043000000000006
>
> Macros, fstream have no effect on results:
> #define XSD_CXX_TREE_FLOAT_PRECISION 3
> #define XSD_CXX_TREE_DOUBLE_PRECISION 3
> #define XSD_CXX_TREE_DECIMAL_PRECISION 3
> ofs.precision(3);
>
> [...]
>
> Msvc8.0 + xsd3.1.0

These macros are only available since XSD 3.2.0. There is a beta
available for 3.2.0 and the final release is coming soon (2-3 weeks):

http://www.codesynthesis.com/pipermail/xsd-users/2008-August/001897.html

Also note that you cannot #define these macros in a file. You need
to specify them in the C++ compiler command line:

-DXSD_CXX_TREE_FLOAT_PRECISION=3


If you need to stick to 3.1.0 then the only way to achieve what you
want is to customize parsing and serialization code for the double
type. This is shown in the following example:

http://www.codesynthesis.com/~boris/tmp/custom-double.zip

Boris



IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.




More information about the xsd-users mailing list