[ 
https://issues.apache.org/jira/browse/COUCHDB-796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878321#action_12878321
 ] 

Adam Kocoloski commented on COUCHDB-796:
----------------------------------------

>From dev@

On Jun 12, 2010, at 3:33 PM, Jason Smith wrote:

> I hate to sidetrack conversation but I am unclear which Couch component has a 
> bug.

No problem, it's good that people understand this.  There are two bugs.  Bug #1 
is that roundtrip encoding/decoding of big numbers in the Erlang VM is not 
supported:

1> Original = <<"[12345678911234567892123456789312345678941234567895]">>.
<<"[12345678911234567892123456789312345678941234567895]">>
2> RoundTrip = couch_util:json_encode(couch_util:json_decode(Original)).
[91,"1.2345678911234567e+49",93]
3> io:format("~s~n", [RoundTrip]).
[1.2345678911234567e+49]

Anything larger than a 32 bit integer is cast to a float.  This is trivial to 
fix, and in fact the behavior is a regression since 0.10.x, when we were 
running a forked mochijson2.

Bug #2 is that the Javascript VM represents Numbers as double precision 
floating-point, so anything with more than 15 digits of precision gets rounded 
off.  I imagine your bigdecimal.js, but it would need the numbers as strings, 
right?  Hence Bob's original suggestion

> Bignum support
> --------------
>
>                 Key: COUCHDB-796
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-796
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: Database Core
>    Affects Versions: 0.11
>            Reporter: Robert Newson
>             Fix For: 1.0
>
>
> CouchDB uses spidermonkey which can only handle 32 bit integer values before 
> overflowing. This might surprise users of map/reduce on large datasets.
> Instead, alter mochijson2.erl to handle bignums and encode numeric values as 
> strings.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to