- From: Markus Lanthaler <markus.lanthaler@gmx.net>
- Date: Wed, 10 Jul 2013 18:46:45 +0200
- To: <public-rdf-wg@w3.org>
On Wednesday, July 10, 2013 6:09 PM, Peter F. Patel-Schneider wrote: > >> 2/ What JSON-native numbers can't be losslessly round-tripped through > >> RDF? > > It depends on the implementation. > > What implementation fits in here? We are talking about taking a bit of > syntax - a JSON number - transforming it using an algorithm in the JSON API > document to another bit of syntax - an RDF literal - and then transforming it > using another algorithm in the JSON API document into another bit of syntax - > a JSON number, again. Lossless round-tripping means that this double > transformation is the identity map. The JSON parser will turn the number into some in-memory representation without preserving the exact representation. That conversion may not be perfect, i.e., it might have rounding errors. > >> 4/ Which xsd datatypes are to be used for the following JSON > numbers? > >> 0.0 > >> 1.1E1 > > xsd:integer > > > > > >> 0.1 > >> 0.00000000000000000000000000000000000000001 > >> 11E-1 > > In most cases xsd:double. > > Most cases? Oh, perhaps you mean that some JSON implementations can't handle > all these or that they round some of them to something that is like an > integer. Exactly. > But, again, these are just pieces of syntax. But as soon as they are parsed by a concrete implementation they are mapped to some in-memory representation. As you know, for ECMAScript that means to store them in a IEEE double > If a JSON implementation could emit > 0.00000000000000000000000000000000000000001 the surely it should be able to > determine that it has a non-zero fractional part and thus should be > transformed into an xsd:double. Right. My PHP implementation happens to support that: http://bit.ly/1diUa0y > Actually a better case would have been > 1.00000000000000000000000000000000000000001 but I don't think that there is > anything different about this one (which is the same as 1.0 in > xsd:double, I think) from the preceeding case. Well, it all depends how numbers are represented internally. -- Markus Lanthaler @markuslanthaler
Received on Wednesday, 10 July 2013 16:47:27 UTC