W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > July 2012

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

From: Andy Seaborne <andy.seaborne@epimorphics.com>
Date: Tue, 31 Jul 2012 09:04:50 +0100
Message-ID: <501791A2.30309@epimorphics.com>
To: public-rdf-dawg-comments@w3.org
CC: David Booth <david@dbooth.org>

Thank you for your comment on serializing xsd:decimal, xsd:float, 

XSD defines the operations for these datatypes including rules for 
precision.  For xsd:decimal, the precision required is:

[[ http://www.w3.org/TR/xmlschema11-2/
All ·minimally conforming· processors must support decimal values whose 
absolute value  can be expressed as i / 10k, where i and k are 
nonnegative integers such  that i < 1016 and k ≤ 16 (i.e., those 
expressible with sixteen total digits).

[[ http://www.w3.org/TR/xmlschema-2/
Note:  All ·minimally conforming· processors ·must· support decimal 
numbers with a minimum of 18 decimal digits

SPARQL uses the work of XQuery/XPath Functions and Operators and the 
requirements for handling these numeric datatypes derive from that body 
of work.  The SPARQL specification links to each operator required.

RDF defines a literal as a lexical form and a datatype.  It does not 
consider the datatype to modify the behavior of forming the RDF literal.

The working group is not planning to make any changes in this area.

I would be grateful if you reply to this message to confirm that the 
working group has responded to your comment.

Yours, on behalf of the SPARQL Working Group,


On 20/07/12 16:19, David Booth wrote:
> 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!
Received on Tuesday, 31 July 2012 08:05:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:01:30 UTC