[xsd-users] comparison operation

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Mon Jul 14 15:57:13 EDT 2008


I ran into an issue comparing two XML objects after a round trip of XML Object->XML string->XML Object.  I traced through the comparison code to find what was being declared different.  It turned out to be in a dateTime because of comparison of the seconds.

In the original object, I set seconds to                            5.0976991653442383

This is serialized as 05.097699, and then the new object has the value 5.0976990000000004

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.

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.

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.

Ray
________________________________
Ray Rizzuto
raymond.rizzuto at sig.com
Susquehanna International Group
(610)747-2336 (W)
(215)776-3780 (C)



________________________________
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