couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Volker Mische <volker.mis...@gmail.com>
Subject Re: Fixed precision of floating point number not respected in views
Date Wed, 20 Feb 2013 13:31:17 GMT
On 02/19/2013 09:46 PM, Luca Morandini wrote:
> On 02/20/2013 01:42 AM, Volker Mische wrote:
>> I think it does address indexes. Only the JavaScript engine will deal
>> with the encoding/decoding. AFAIK SpiderMonkey/V8 doeas the right thing.
> 
> I did a quick check:
> 
> 
> lmorandini@vaneyck: >node
>> var n= {"n": 17.3};
> undefined
>> console.log(n.n);
> 17.3
>> 17.0 + 0.3
> 17.3
> Right!
> 
> ...but:
> function(doc) {
>   emit(doc._id, [17.3, 17.0 + 0.3]);
> }
> 
> lmorandini@vaneyck: >curl -X GET
> http://localhost:5984/datastore/_design/main/_view/numbertest
> {"total_rows":12,"offset":0,"rows":[
> {"id":"a0046a217ccabb616007fce0980008c6","key":"a0046a217ccabb616007fce0980008c6","value":[17.300000000000000711,17.300000000000000711]},
> ...
> Wrong!
> 
> Therefore, I would argue this is not a feature intrinsic to JSON or
> JavaScript.
> 
> I appreciate suggestions from other members of the list, but changing
> numbers to integers or multiplying them (essentially the same
> suggestion) is not an option, since I have little control over input
> data, and it will kill performance  too (I deal mainly with geo-spatial
> data, hence heaps of numbers in arrays of arrays).
> 
> Well, there it goes my academic track paper on CouchDB and GeoCouch for
> FOSS4G '13 :(

I don't understand why this would be a problem for an *academic* paper.
People should understand the implications of float point numbers.

Cheers,
  Volker

Mime
View raw message