[ https://issues.apache.org/jira/browse/COUCHDB749?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12860657#action_12860657 ]
Thad Guidry commented on COUCHDB749:

Researched at one time on http://www.programmersparadox.com/2008/02/05/erlangintegers/
February 6, 2008 @ 12:58 am
Comment by Nic:
Arbitrarysized 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).
36028797018963970.0
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 IEEE754 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: COUCHDB749
> URL: https://issues.apache.org/jira/browse/COUCHDB749
> 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 it.
> 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.