couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Davies (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COUCHDB-227) Large Number Support Bug
Date Mon, 26 Jan 2009 15:57:59 GMT

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

Jason Davies commented on COUCHDB-227:
--------------------------------------

This is due to JavaScript 1.x representing all numbers as 64-bit floating point numbers, which
means only 15 digits of reliability for integers (see http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference).

JSON itself effectively allows arbitrary-precision decimals, as JSON is just a general-purpose
data description language.  I am guessing that if the Python view server is used, then the
view will return the correct values (as Python supports long integers).

I did some research into JavaScript and precision because I wanted to use CouchDB to do financial
calculations (e.g. summation of product prices).  ECMAScript 4 (or JavaScript 2) seems to
support "real decimals":

http://intertwingly.net/blog/2008/07/11/Decimal-in-ECMAScript
http://dev.opera.com/articles/view/why-i-love-ecmascript-4-real-decimals/

I'm not sure when Spidermonkey will have ECMAScript 4, but when it does it looks like we'll
get all the juicy benefits of real decimals.  In the meantime, we should document this in
case it gives anyone a nasty surprise...

> Large Number Support Bug
> ------------------------
>
>                 Key: COUCHDB-227
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-227
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Administration Console, JavaScript View Server
>            Reporter: Adam Kocoloski
>
> It looks like SpiderMonkey rounds large integers.  To reproduce,  create a document in
Futon with a field value
> 9999999999999999
> Futon will round this to 10000000000000000.  Or, create a document with that field value
by some other means and then emit the field in a view.  The document will have the correct
value for the field, but the value in the view will be wrong.

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


Mime
View raw message