Hi,
I just recently started to look at couchdb but I already love so many aspects
of it.
One thing that really worries me though is something I encountered today:
CouchDB seems to think that 0.79 + 5.99 + 1.59 = 8.370000000000001
This is the only document I have in my database:
{
"_id": "xyz",
"_rev": "...",
"item": "BMW 320d",
"prices": {
"Base Price": 1.59,
"Extra 1": 5.99,
"Extra 2": 0.79
}
}
This is my map / reduce function:
function(doc) {
var p;
for (p in doc.prices) {
emit(doc.item, doc.prices[p])
}
}
function(keys, values){
return sum(values);
}
Calling with group=true this results in
{"rows":[
{"key":"BMW 320d","value":8.370000000000001}
]}
I could always just multiply my numbers with the precision I need and work with
ints but I'm still curious to see this explained.
Michael