w3c / rdf-concepts

https://w3c.github.io/rdf-concepts/
Other
11 stars 4 forks source link

rdf:JSON equality of +0 and -0 #91

Open pfps opened 3 weeks ago

pfps commented 3 weeks ago

Is +0 equal to -0 or not? Equality of IEEE floating point double would indicate so but equality for rdf;JSON says they have to be the same value which means that they are not equal. If the latter is desired there should be a note along the lines of

0 and -0 compare equal in IEEE floating point double. RDF, however, uses a notion of true equality for datatype values. As 0 and -0 are different values in the value space of rdf:JSON they are not equal as far as rdf:JSON is concerned.

gkellogg commented 3 weeks ago

This should be the same as asking if "+0"^^xsd:double is equal to "-0"^^xsd:double. For the XML Schema Datatypes says "Equality is identity, except that 0 = −0 (although they are not identical) ...." so "+0"^^xsd:double == "-0"^^xsd:double. By that reasoning, "+0"^^rdf:json == "-0"^^rdf:json, as the value space for JSON numbers is xsd:double.

pfps commented 3 weeks ago

On the contrary. As far as the value spaces of rdf:JSON and xsd:double are concerned +0 and -0 are different values, and thus not identical and thus, as far as RDF is concerned, not equal. There might be a SPARQL relationship called equality that says that +0 and -0 are equal, but that is a different relationship and why using "equality" for the relationship in the RDF value space is probably not a good idea.

Somewhat similar concerns exist for rdf:HTML and rdf:XMLLiteral. Their value spaces are DOM trees considered as trees, not data structures. So two different structures in memory are the same element of the value space if they compare as equal even though the data structures might have different internal pointers.