- From: Markus Lanthaler <markus.lanthaler@gmx.net>
- Date: Thu, 4 Apr 2013 15:34:43 +0200
- To: <public-rdf-wg@w3.org>
On Thursday, April 04, 2013 2:58 PM, Andy Seaborne wrote:
> Minor:
>
> "1.99999999999999999999"^^xs:double isn't a double or at least not the
> double you may think it is . It is outside the precision range for
> doubles which is 53 bits. As JSON uses doubles, effectively, they do
> roughy align on xs:double.
>
> http://www.w3.org/TR/xmlschema11-2/#double
That's true, at least for JavaScript which (in the current version)
internally uses 64 bit floating point numbers.
> A decimal is arbitrary precision in XSD:
>
> "1.99999999999999999999"^^xs:decimal
>
> Decimals minimum precision is 18 digits.
>
> and also
> http://www.w3.org/TR/xsd-precisionDecimal/
That's why we don't convert decimals at all.. They will remain strings in
the form
{
"@value": "1.99999999999999999999",
"@type": "xs:decimal"
}
> > Should these be forced to
> > remain in expanded form, to avoid this changing of value and even
> type?
> > On this, I suggest expanded form be required if practical -- but I'm
> not
> > sure it's always clear when it's required.
> >
> > These basically boil down to what kind of fidelity is to be
> guaranteed
> > by round-tripping RDF->JSONLD->RDF.
>
> which is a very good question
I've more or less rewritten the Data Round Tripping section [1]. I hope it
is much clearer now:
http://json-ld.org/spec/latest/json-ld-api/#data-round-tripping
By default, XSD integers and doubles are converted to JSON-native numbers,
which is what most developers would expect. If precision or the exact
lexical form matters, the "use native types" flag of the Convert from RDF
algorithm [2] can simply be set to false and no literals will be converted.
[1]
https://github.com/json-ld/json-ld.org/commit/11ea074d054acf20704f5330905194
3043066986
[2] http://json-ld.org/spec/latest/json-ld-api/#convert-from-rdf-algorithm
--
Markus Lanthaler
@markuslanthaler
Received on Thursday, 4 April 2013 13:35:30 UTC