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 4FADAE201 for ; Tue, 19 Feb 2013 09:09:21 +0000 (UTC) Received: (qmail 3527 invoked by uid 500); 19 Feb 2013 09:09:19 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 3493 invoked by uid 500); 19 Feb 2013 09:09:19 -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 3482 invoked by uid 99); 19 Feb 2013 09:09:19 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2013 09:09:19 +0000 Received: from localhost (HELO mail-lb0-f169.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2013 09:09:18 +0000 Received: by mail-lb0-f169.google.com with SMTP id m4so4948737lbo.0 for ; Tue, 19 Feb 2013 01:09:16 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.152.132.170 with SMTP id ov10mr13356076lab.21.1361264956614; Tue, 19 Feb 2013 01:09:16 -0800 (PST) Received: by 10.112.25.201 with HTTP; Tue, 19 Feb 2013 01:09:16 -0800 (PST) In-Reply-To: References: Date: Tue, 19 Feb 2013 09:09:16 +0000 Message-ID: Subject: Re: Fixed precision of floating point number not respected in views From: Robert Newson To: "user@couchdb.apache.org" Content-Type: text/plain; charset=ISO-8859-1 "I have stored fixed precision numbers in a database". You haven't, unfortunately, because you can't. Javascript only has one kind of number, 64-bit floating point. If you want fixed precision, you'll need to store your numbers in strings and manipulate them that way too. A quick google in the past has shown a few "bignum" libraries for Javascript. B. On 19 February 2013 08:20, Luca Morandini wrote: > On 02/19/2013 07:05 PM, Luca Morandini wrote: >> >> Folks, >> >> I have stored fixed precision numbers in a database, but when they are >> spit out by >> a view, the precision is full, and -which is worse- the trailing decimal >> digits >> are not all zeroes. > > > In the CouchDB: The Definitive Guide", I have found out that "most clients" > would interpret, say, 15.7 as 15.69999999999 (or so), which I suppose is > exactly what I observed... but what is meant as "client" in this context, a > view engine ? > > Anyway, any view to tune this feature of the JavaScript view engine ? > > > Regards, > > Luca Morandini > Data Architect - AURIN project > Department of Computing and Information Systems > University of Melbourne > Tel. +61 03 903 58 380 > Skype: lmorandini >