Re: OK to use decimal for 0.3 in turtle?

Dave Beckett wrote:
> 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.

I agree - that would be good.

> 
> 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.

If the form has and "e" then it will be a double, following XQuery/XSLT.

Adding in "f" form is doable - if there is call, then all the
syntaxes (SPARQL, cwm, Turtle) shoudl be the same here.

> 
> 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?)

SPARQL does not require support for float. As with F&O, if a promotion is 
needed, then it is to double, not trying float.

Is there sufficient use of float to make it worthwhile?  The cost as I see it 
is support for doing float arithemtic, not the grammar.

> 
> 
> 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.
> 

This worried me for a while but I found that F&O does not require arbitrary 
precison - it requires 18 places and impls are free to do better.  Currently, 
I have to decide this at just one point (divide for Java 1.4 requires explicit 
precision - I fixed on 24 for now as large).  Java 1.4 and 1.5 are OK (1.5 is 
better than 1.4).

> 
> 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

Thanks for the response

	Andy

Received on Tuesday, 22 November 2005 11:40:24 UTC