You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2021/10/22 21:18:04 UTC

[GitHub] [couchdb] yxuco opened a new issue #3797: Cannot sum BigInt

yxuco opened a new issue #3797:
URL: https://github.com/apache/couchdb/issues/3797


   ## Description
   
   I tried to use the following reduce function to sum big numbers, but the returned value is null.  How should I sum big numbers in a reduce function?
   
   ```
   function (keys, values, rereduce) {
     let s = BigInt(0);
     values.forEach(v => {
         s += BigInt(v);
     });
     return s.toString();
   }
   ```
   
   ## Steps to Reproduce
   
   In Fauxton UI,
   * Create 2 docs that contains an attribute value of "29319221615428073";
   * Create a view using the above reduce function;
   * Run a query with reduce turned on 
   
   ## Expected Behaviour
   
   The query result should show the sum of the big numbers, e.g. `58638443230856146` if there are 2 of the docs with the same value of `29319221615428073`.  But the actual result of the query is "null".
   
   ## Your Environment
   
   {"couchdb":"Welcome","version":"3.1.1","git_sha":"ce596c65d","uuid":"b8bdfb1c362410c3459c81b25214b276","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
   
   * CouchDB version used: 3.1.1
   * Browser name and version: Brave
   * Operating system and version: macOS Big Sur
   
   ## Additional Context
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] janl commented on issue #3797: Cannot sum BigInt

Posted by GitBox <gi...@apache.org>.
janl commented on issue #3797:
URL: https://github.com/apache/couchdb/issues/3797#issuecomment-950735085


   We cleared this up in Slack, this due to SpiderMonkey 60 being part of the Mac binary and BigInt only being available in 68+. Here is an experimental build with SM86: https://clients.neighbourhood.ie/couchdb/releases/3.2.0/


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] janl closed issue #3797: Cannot sum BigInt

Posted by GitBox <gi...@apache.org>.
janl closed issue #3797:
URL: https://github.com/apache/couchdb/issues/3797


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb] yxuco commented on issue #3797: Cannot sum BigInt

Posted by GitBox <gi...@apache.org>.
yxuco commented on issue #3797:
URL: https://github.com/apache/couchdb/issues/3797#issuecomment-950050042


   I worked around the issue by using `parseFloat(v)` instead of `BigInt(v)`, although I am curious why BigInt does not work.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org