couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: json/couchdb integer min max values
Date Sun, 22 Mar 2009 23:08:58 GMT
On Sun, Mar 22, 2009 at 6:24 PM, Adam Kocoloski <kocolosk@apache.org> wrote:
> 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.
>

Touché. Though there is erlview now which might alleviate things if
its super important data that can't be approximated or worked around
in some other fashion.

> 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,
>
> Adam
>
> 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] http://erlang.org/doc/man/erlang.html
>>
>> On Sun, Mar 22, 2009 at 6:06 PM, Evan McLean <evan@michevan.id.au> 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.
>>>
>
>

Mime
View raw message