To answer the original question, _sum can only sum numbers, it does not understand numbers inside strings.
On 15 November 2013 10:27, Andy Wenk <[email protected]> wrote: > sidenote: super cool talk by Bartek Szopka about floating point numbers in > JavaScript (and other languages) held at JSConf.eu 2013 > > https://www.youtube.com/watch?v=MqHDDtVYJRI > > > On 15 November 2013 11:00, Mike Marino <[email protected]> wrote: > >> Hi Pedro, >> >> On Fri, Nov 15, 2013 at 10:29 AM, Pedro Narciso García Revington >> <[email protected]> wrote: >> > Hi, >> > >> > I want to sum decimals with the builtin _sum function. >> > My documents look like >> > { >> > "_id": "7a2c5e50dfeb1341d02aa27c7a05f629", >> > "_rev": "4-482ff2f6b6e5c2aa079e3e4114d02093", >> > "type": "payment", >> > "amount": "0.2" >> > } >> > I store the numbers as strings because I read this the proper way for >> > decimals. >> >> I would echo Stefan's suggestion in this case since you're dealing >> with adding "money" numbers. Otherwise, you have to deal with normal >> numerical rounding issues when performing operations on floats. >> >> > >> > If I try to sum them with the builtin _sum I get the following error >> > "builtin _sum function requires map values to be numbers" >> > >> > I removed the quotes from the numbers. Now I can sum them but 0.2 + 0.1 >> > equals to 2.99999999 >> >> Was this a typo? Did you mean 0.2999999 ? >> >> Cheers, >> Mike >> > > > > -- > Andy Wenk > Hamburg - Germany > RockIt! > > http://www.couchdb-buch.de > http://www.pg-praxisbuch.de > > GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588
