incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kocoloski <>
Subject Re: json/couchdb integer min max values
Date Sun, 22 Mar 2009 22:24:05 GMT
Nope, unfortunately it doesn't just work.  On the Erlang side  
everything is certainly fine, but JavaScript uses IEEE doubles to  
represent Numbers.  You get ~15 digits of precision before funny  
things start happening in views, IIRC.

If you need precise storage of large numbers, you'll need to store  
them as strings.  You can still use the strings as view keys without  
any trouble at all.

I'm no JavaScript pro, but someone on IRC (Jason Davies, maybe?)  
mentioned that future versions of ECMAScript may have better BigNum  
support.  Hope that helps,


On Mar 22, 2009, at 6:16 PM, Paul Davis wrote:

> IIRC, the JSON RFC either doesn't mention limits whatsoever or only
> mentions that there is no limit.
> A quick glance at mochijson2.erl which is CouchDB's JSON decoder looks
> like its using list_to_integer for its conversion routine. The docs at
> [1] on list_to_integer don't mention limits. I'm not at all certain,
> but I think that erlang has builtin large number support so it may
> Just Work &trade;. But tracking down any caveats on list_to_integer/1
> should give you what you need.
> HTH,
> Paul Davis
> [1]
> On Sun, Mar 22, 2009 at 6:06 PM, Evan McLean <>  
> wrote:
>> Is it documented anywhere what the minimum and maximum values for  
>> an int
>> are in couchdb and/or json?
>> Based on a 32 bit integer?
>> I had a quick scan through the json RFC and couldn't find anything.
>> How would you go about efficiently handling very large numbers,
>> especially if you wanted to use them in (sorted) keys?
>> E.

View raw message