Serializing xsd:decimal, xsd:float, xsd:double

It is currently difficult to compare the results of two different SPARQL
servers when xsd:decimal, xsd:float or xsd:double are used, because
there does not seem to be any standard way to control the number of
decimal places that are serialized.  For example, if the decimal
0.049508196721311475409836 is computed, one server may serialize this as

  "0.0495081967"^^xsd:decimal

and another may serialize it as

  "0.050"^^xsd:decimal

One might (erroneously) attempt to round both of the serialized values
to one decimal place in order to compare them, but if they have already
been rounded once before serialization (as above) then this won't work,
because 0.050 rounds to 0.1, while 0.0495081967 rounds to 0.0.

I think the SPARQL standard should provide some "SHOULD" guidance, such
as specifying that a SPARLQ server SHOULD (by default) serialize a
specified number of decimal places (perhaps all available), and MAY
provide a standard means of controlling the number of decimal places
that are serialized.

If it is too late in the WG process to consider this for SPARQL 1.1 (and
I assume it is) then please add this to the wish list for the next
version.

Thanks!

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.

Received on Friday, 20 July 2012 15:20:23 UTC