deewreck
deewreck

Reputation: 133

Javascript large Number parsing

I am using a Couchbase view to emit a few records. Among those records, there is one record which is 19 digit long. When Couchbase view (written in javascript) pulls those record, it rounds off the record into smaller one and loses precision.

-7092643922943239825 is actual number but when retrieved from below view:

function(doc, meta) {
if (doc.docType == 'xyz') {
    if (doc.source) {
            if (doc.source != null) {
                emit([doc.valA, doc.valB,  loc], 1);
            }
    } 
}

The output I get is:

[ **-7092643922943240000, 1523365218128317200**, "abc" ]

I was expecting:

"doc": {
  "valA": 1523365218128317302,
  "valB": -7092643922943239825
}

What am I doing wrong?

Upvotes: 1

Views: 52

Answers (1)

Jon Strabala
Jon Strabala

Reputation: 586

It seems like you have cross posted this question, please refer to a detailed discussion concerning your issue as posted to https://forums.couchbase.com/t/couchbase-view-rounds-off-the-long-value-in-emit/34370 (the link was previously referenced by dnault)

Upvotes: 0

Related Questions