couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thad Guidry (JIRA)" <>
Subject [jira] Commented: (COUCHDB-749) CouchDB does not persist large values of Numbers correctly.
Date Sun, 25 Apr 2010 05:42:49 GMT


Thad Guidry commented on COUCHDB-749:

Researched at one time on

February 6, 2008 @ 12:58 am
Comment by Nic:
Arbitrary-sized integer is nice but poorly supported in Erlang.
If one only uses additions or multiplications its okay but
integer power arithmetic operation is not supported. So it
is untrue to say that Erlang can do integer arithmetic of
arbitrary length integers. Even worse, it does not warns you
when it produces a wrong answer. Try the following:
1> math:pow(2,55).
Obviously no integral power of 2 can end by 0.
All integral powers of 2 larger than 55 will give you a result
ending by zero. This is because Erlang has not implemented
an integer power function and relies on a float pow(x,y) function.
This is why the result is a float. Actually it is an IEEE-754 float
number in decimal64 format which means it has a maximum
precision of 16 digits.
Many applications dealing with large integers require true
large integer arithmetic (including power), for example
cryptology applications routinely do arithmetic modular
power operations on very large integers. Though Erlang
allows to write arbitrary large integers and do some basic
operations it surely cannot be said to support arlitrary large
integer arithmetic. For that, one can use mathematica (does
arbitrary large float arithmetic as well) or specialized packages
such as simod/modsim.

> CouchDB does not persist large values of Numbers correctly.
> -----------------------------------------------------------
>                 Key: COUCHDB-749
>                 URL:
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.11
>         Environment: All
>            Reporter: Jarrod Roberson
> All the following operations exhibit the same bug, large numbers don't get persisted
correctly. They get something added to them for some reason.
> 9223372036854775807 == java.lang.Long.MAX_VALUE
> 1: go into Futon, create a new document and create a new field and enter the number 9223372036854775807,
click the green check mark, the number changes to 9223372036854776000 even before you save
> 2.curl -X PUT http://localhost:5984/test/longTest -d '{"value": 9223372036854775807}',
the number gets persisted as 9223372036854776000
> trying to persist System.currentTimeMilliseconds() from java causes the same thing to
happen occasionally.
> This seems to be a pretty serious bug if I can't trust that my data is not being corrupted
when submitted to the database.

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

View raw message