Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 436009143 for ; Mon, 16 Jul 2012 16:49:13 +0000 (UTC) Received: (qmail 87848 invoked by uid 500); 16 Jul 2012 16:49:11 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 87809 invoked by uid 500); 16 Jul 2012 16:49:11 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 87801 invoked by uid 99); 16 Jul 2012 16:49:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 16:49:11 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of space.ship.traveller@gmail.com designates 74.125.83.52 as permitted sender) Received: from [74.125.83.52] (HELO mail-ee0-f52.google.com) (74.125.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2012 16:49:03 +0000 Received: by eeke51 with SMTP id e51so450823eek.11 for ; Mon, 16 Jul 2012 09:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=73MfMeuaWlFXxQdp+rAVPmMZjjS5T4f7wsldr0ZQfbI=; b=xBOwkF22FHc/cWdN1YMiFjxHKrnxvn+gQxfX0jG5WAayc2CtAUskAeod8Iwqj5L07C vgemGCs/IKSfTjXABvZ2F7TmJkIc0JLBaza865RD6jF5094vgIE6bt0O1QUBM7SDLw4Z HtwemMz6SgkCfam6eITVvx6Hm6zP5DMzf4Y+ORFUYmhZ7+uF8cnx2qHE3OYgj0z4MG5l cAaeoOxQyEcNu6d7mkyl5j6/3xB/KxGXKDZ3FlZH7LSkvoJdRpl4+uBmFSUEFVsux0Qa ewQ7CFhEkBZnDkUBgCo5rD+whUUnGQqNOvvs9Iifem0SuJtJfARM8jfbo27RixMyZIfL Xa9w== MIME-Version: 1.0 Received: by 10.14.180.67 with SMTP id i43mr10040496eem.23.1342457323678; Mon, 16 Jul 2012 09:48:43 -0700 (PDT) Received: by 10.14.224.1 with HTTP; Mon, 16 Jul 2012 09:48:43 -0700 (PDT) In-Reply-To: References: <966B21E1-B4F8-42CF-A266-C562AA0D7E8E@apache.org> Date: Tue, 17 Jul 2012 04:48:43 +1200 Message-ID: Subject: Re: Numerical accuracy and precision From: Samuel Williams To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=047d7b603b84e76b6e04c4f53331 --047d7b603b84e76b6e04c4f53331 Content-Type: text/plain; charset=ISO-8859-1 Hi Robert, Thanks for the clarification, I appreciate your prompt and detailed response. The view server for Ruby seemed a bit "abandoned".. is any work being done on this? Kind regards, Samuel On 17 July 2012 04:28, Robert Newson wrote: > The built-in reduce functions are executed in erlang, which has arbitrary > precision for integers and 64-bit precision for floating point. > > The JSON standard is notoriously poor around numbers but couchdb does as > straight a translation as possible. > > The maximum integer possible in javascript without rounding is 2^53 > (9,007,199,254,740,992). This is a fair multiple of the world's GDP, for > context. > > I haven't seen a recommendation for a big integer library and there's a > jira ticket (that I raised) to include arbitrary precision math in couchdb > as standard. > > There are view servers available for both Python and Ruby. > > B. > > On 16 Jul 2012, at 16:33, Samuel Williams wrote: > > > Well, I'm using a big integer library for accounting in Ruby, but I'm not > > sure how to do map-reduce with JavaScript without potentially corrupting > > values... what is the recommended approach? > > > > Also, what is the precision of _sum and other builtin reductions? > > > > Is there a recommended big integer library for use with the > > JavaScript/SpiderMonkey interpreter and is this documented anywhere? With > > the natural JSON format, I assume there are no limitations to integer > size, > > but clearly JSON -> JavaScript object will impose some data type > > limitations... it seems like a language with built in support for big > > integers would be ideal, e.g. Python, Ruby, rather than JavaScript. > > > > Kind regards, > > Samuel > > > > On 17 July 2012 02:27, Robert Newson wrote: > > > >> > >> Correct, numeric precision using the javascript view engine is limited > to > >> the 64-bit floating point numbers that spidermonkey supports. > >> > >> For arbitrary precision math, encode your values as strings and use a > >> bignum library. > >> > >> As an aside, if you're using floating-point numbers in an accounting > >> context, you have already fallen into sin. > >> > >> B. > >> > >> On 16 Jul 2012, at 15:01, Samuel Williams wrote: > >> > >>> Hi, > >>> > >>> I'm wondering, when using the JavaScript backend, is the numerical > >> accuracy > >>> limited to that of JavaScript? > >>> > >>> How can we implement a numerically correct sum function, e.g. using a > big > >>> integer implementation? > >>> > >>> Kind regards, > >>> Samuel > >> > >> > > --047d7b603b84e76b6e04c4f53331--