Repository navigation
Conversation
pjfanning
left a comment
There was a problem hiding this comment.
Two non-blocking notes:
XmlObject.valueEquals,compareValueandvalueHashCodechange for0/-0, so this deserves a line in the release notes.- I am not sure about the spec citation. From memory the wording on signed zero differs between the XML Schema 1.0 editions and 1.1 (I have not rechecked it), so it may be worth confirming the reference. Agreement with Xerces is the stronger argument for the change in any case.
|
Good instinct on the citation, I'd quoted the value space line and that's the weak form of the argument. The direct sentence is in 1.0 2E 3.2.4, repeated in 3.2.5 for double: "This datatype differs from that of [IEEE 754-1985] in that there is only one NaN and only one zero." I've updated the description to that and the code comments now name the sections. The wording does differ in 1.1, as you remembered. 3.3.4 and 3.3.5 put Worth flagging that the other half of that 1.1 change runs the opposite way: 1.1 makes NaN != NaN, where 1.0 has NaN equal to itself. XMLBeans follows 1.0 there and this patch deliberately leaves it be, so the bit tie-break stays for NaN. On the release notes, CHANGES.txt stops at 5.0.1 and points at status.html, so there's nothing in the tree for me to edit. Line if it's useful:
Glad to put that wherever the notes actually live if you'd rather it came in with the change. |
[xs:float] minInclusive 0, value -0
XMLBeans = INVALID: cvc-minInclusive-valid
Xerces = VALID
Found these in a differential run of XmlObject.validate() against the JDK Xerces validator over xs:float and xs:double: 14 disagreements, every one with -0 on a side.
They all come from JavaFloatHolder.compare, which drops through to a floatToIntBits tie-break once neither < nor > holds. floatToIntBits(-0.0f) is 0x80000000, so -0 sorts below 0 and never compares equal to it. JavaDoubleHolder.compare does the same with doubleToLongBits. The tie-break is there for NaN, which has to equal itself although NaN == NaN is false in Java; signed zero reaches it by accident. XML Schema Part 2 1.0 2E 3.2.4 is explicit about it: "This datatype differs from that of [IEEE 754-1985] in that there is only one NaN and only one zero." 3.2.5 says the same for double. 1.1 3.3.4 and 3.3.5 keep both zeros in the value space but define equality as identity "except that 0 = -0", and add that "0 and -0 are thus equivalent for purposes of enumerations and identity constraints, as well as for minimum and maximum values". Either edition gives the same answer here.
Four observations. xs:unique and xs:key miss a duplicate pair 0 / -0, because IdentityConstraint keys field values on valueEquals and valueHashCode. xs:keyref rejects a reference written -0 against a key written 0. minInclusive='0' rejects -0 and maxInclusive='-0' rejects 0, while minExclusive='-0' accepts 0, and enumeration value='0' does not match -0. XmlObject.valueEquals, compareValue and valueHashCode disagree with the value space.
Both compare methods now return 0 when the two values are IEEE-equal, ahead of the bit tie-break, and value_hash_code maps -0 onto 0 so valueEquals and valueHashCode stay in step. NaN keeps the tie-break, so it still equals itself and nothing else. Every other value behaves as before, and all 14 cases agree with Xerces after the change. Regression test added.