W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2005

Re: OK to use decimal for 0.3 in turtle?

From: Dave Beckett <dave@dajobe.org>
Date: Tue, 22 Nov 2005 00:50:06 -0500
Message-ID: <4382B18E.9040508@dajobe.org>
To: Dan Connolly <connolly@w3.org>
Cc: public-cwm-talk@w3.org, RDF Data Access Working Group <public-rdf-dawg@w3.org>

Dan Connolly wrote:
> Dave,
> 
> At XML 2005, we discussed this change:
> 
> RESOLVED: change dataytpe for SPARQL floating point numerics to
> xsd:decimal contingent on Beckett's agreement to a similar
> change in Turtle.
>  --
> http://lists.w3.org/Archives/Public/public-rdf-dawg/2005OctDec/att-0229/Nov15.html#item02
> 
> You seemed pretty much OK with the change, but I heard "I just
> need to check one more thing" disclaimers on your answers.
> 
> Are you OK with the change?

I had a few concerns with sparql/turtle syntax alignment.  As I was 
composing this I found some more :)


1) I want to keep Turtle aligned with Notation 3 as implemented in cwm 
as far as is possible.

So I made a test file turtle1.ttl with some numeric examples:
------------
@prefix : <http://example.org#> .
:a :b 1.0 .
:c :d 1 .
:e :f 1.0e0 .
------------

and ran cwm on it fresh from a CVS checkout:

$ cwm -n3 -ntriples turtle1.ttl

     <http://example.org#a>     <http://example.org#b> 
"1.0"^^<http://www.w3.org/2001/XMLSchema#double> .

     <http://example.org#c>     <http://example.org#d> 
"1"^^<http://www.w3.org/2001/XMLSchema#integer> .

     <http://example.org#e>     <http://example.org#f> 
"1.0"^^<http://www.w3.org/2001/XMLSchema#double> .

(*aside - note that the original lexical forms are not preserved; see 
the last case)

so my OK is conditional on N3 also making this change to xsd:double.

My test version of raptor (1.4.8 to be) gives the same answers as cwm:
$ rapper -q -i turtle -o ntriples turtle1.ttl
<http://example.org#a> <http://example.org#b> 
"1.0"^^<http://www.w3.org/2001/XMLSchema#double> .
<http://example.org#c> <http://example.org#d> 
"1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org#e> <http://example.org#f> 
"1.0"^^<http://www.w3.org/2001/XMLSchema#double> .


2) Is there going to remain a shorthand syntax for xsd:double 
[xsd:float] also?

In C there is 1.0f (float) as well as variants.  Other languages have 
similar abbreviated forms.

Writing "1.0"^^xsd:double each time will be tedious (plus you have to 
define the xsd: namespace as there are no default pre-defined namespaces 
in sparql or turtle).

So what does XQuery do?  Finding
   http://www.w3.org/TR/xquery/#id-literals
it has forms for integer, decimal and double (with an 'e' or 'E').

Looks like they don't care about float.

Maybe sparql, turtle/n3 should follow that.  It seems odd to not have 
short forms for constants for numeric datatypes that sparql supports and 
that n3/cwm uses given that they can be made relatively unambiguous. 
(What datatypes does cwm do artithmetic in?)


3) Iplementing arbitrary length decimal numbers

I was worried about this, mostly in C as that's what I use.

I did some research and I was happy that not only is there a GNU mp 
library (GPLed) and other implementations but there is ongoing work to 
add it to the C language, and there is a branch of code being added to 
GCC to support it, based on reference open source code.  These are the 
pointers I found:

   http://www2.hursley.ibm.com/decimal/
   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1107.htm
   http://gcc.gnu.org/viewcvs/branches/dfp-branch/

(note that gcc recently moved to subversion so some of the gcc pointers 
in the ibm site are out of date)

So on the this final point I'm ok for myself.  There might be other 
languages that don't have such libraries, although conversely there are 
some with it builtin: python 2.4, java recent, ruby? at a quick search.


4) Negative numbers in Turtle/sparql/n3.

This was mentioned by AndyS (I think) as omitted from turtle and/or 
sparql probably by accident.

I'd like alignment on this too.  Here's a test file turtle2.ttl:
-------
@prefix : <http://example.org#> .
:a :b -1.0 .
:c :d -1 .
:e :f -1.0e0 .
-------

which cwm passes fine (returning the double types) but looks like it is 
not syntax in the grammar/my code for Turtle.  So I need to fix this.

Cheers

Dave
Received on Tuesday, 22 November 2005 05:50:45 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:24 GMT