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

Hi Andy,

On Tue, 2012-07-31 at 09:04 +0100, Andy Seaborne wrote:
> David,
> 
> Thank you for your comment on serializing xsd:decimal, xsd:float, 
> xsd:double.
> 
> 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.

Should I understand this to mean that when a minimally conforming SPARQL
server creates a value of type xsd:decimal, then at least 18 decimal
digits of precision must be retained in *serializing* that value to
lexical form?  I understand that the computations must be performed with
at least 18 decimal digits of precision, but serialization is
(potentially) a different matter.

Thanks,
David


> 
> 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,
> 
>  Andy
> 
> 
> 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!
> >
> 
> 

-- 
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 Tuesday, 31 July 2012 14:05:53 UTC