nickva commented on issue #1152: Inconsistent sum and sumsqr aggregates of floating point numbers URL: https://github.com/apache/couchdb/issues/1152#issuecomment-364268192 Floating point numbers, as most languages implement them, are not associative. That is a+(b+c) doesn't equal to (a+b)+c. Printing the number is not enough, it's best to do the comparison: Python ``` >>> x = 0.1 + (0.2 + 0.3) >>> y = (0.1 + 0.2) + 0.3 >>> x == y <<< False ``` JS ``` x = (0.1 + 0.2) + 0.3 0.6000000000000001 y = 0.1 + (0.2 + 0.3) 0.6 x == y false ``` The sum is a reducer in this case. For it to work properly the operation has to be associative, such that it doesn't matter what order the keys are presented to it, it will produce the same result. Or, alternatively, the keys always have to be presented in the same order. Notice that with q=1,n=1 or in CouchDB 1.x the second part is true, the keys are processed in the same order (but you don't get any benefits of sharding).
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
