[xsd-users] comparison operation

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Wed Aug 27 18:26:54 EDT 2008


Boris,

Is there a way to use the new 3.2.0 feature that address the precision of float/double to "fix" the representation issue?

I.e. if my original double is rounded to XSD_CXX_TREE_DOUBLE_PRECISION places.  If I take the rounded value, serialize and deserialize it via my XSD-generated library, would the deserialized value be guaranteed to compare equal to the rounded version I serialized?

Ray

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Monday, July 14, 2008 4:19 PM
To: Rizzuto, Raymond
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] comparison operation

Hi Ray,

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

> So, there are two effects going on here. One is that the serialization to
> XML loses digits after microseconds. The other is conversion from a string
> to a double can run into representation issues.

Correct on both counts.


> I am not sure if it is worth addressing the first issue - microseconds
> may be sufficient for most purposes. In my code, I think I can limit
> the value to 6 decimal places fairly easily.

Yes, we have to pick some default value and microseconds seems like
a reasonable compromise. You always have an option to customize the
dateTime type and serialize the seconds component with your desired
precision.


> The representation issue isn't an issue for precision, but it certainly
> affects any comparison of types that rely on doubles. I'm not sure if
> there is a good answer here.

I don't think there is a practical solution to this one since that's
how floating point types work. So the only suggestion I can offer is
to choose floating point values for your test so that they don't
trigger this problem.

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