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 05A4C100D1 for ; Fri, 15 Nov 2013 17:58:34 +0000 (UTC) Received: (qmail 53822 invoked by uid 500); 15 Nov 2013 17:58:29 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 53771 invoked by uid 500); 15 Nov 2013 17:58:27 -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 53719 invoked by uid 99); 15 Nov 2013 17:58:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Nov 2013 17:58:27 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jens@couchbase.com designates 206.225.164.31 as permitted sender) Received: from [206.225.164.31] (HELO EXHUB020-4.exch020.serverdata.net) (206.225.164.31) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Nov 2013 17:58:21 +0000 Received: from EXVMBX020-1.exch020.serverdata.net ([169.254.4.151]) by EXHUB020-4.exch020.serverdata.net ([206.225.164.31]) with mapi; Fri, 15 Nov 2013 09:58:00 -0800 From: Jens Alfke To: "user@couchdb.apache.org" Date: Fri, 15 Nov 2013 09:57:59 -0800 Subject: Re: decimal and builtin _sum function Thread-Topic: decimal and builtin _sum function Thread-Index: Ac7iLDjbT57Ld45XSDSVn9EsBZR0tw== Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org On Nov 15, 2013, at 9:31 AM, Mark Hahn wrote: >> When you store and then retrieve the number 0.3, you'd really like to kn= ow >> that it will come back in the same form. Without knowing about the innar= ds >> of CouchDb and how it processes JSON, that's hard to guarantee. >=20 > A JS number is the same whether going through JSON or not. There is no > possible change. That=92s not true. JavaScript usually stores numbers as 64-bit IEEE floatin= g point. JSON is a _textual_ format, so converting numbers to JSON involves= writing them as strings, which is a lossy conversion. It=92s especially lo= ssy if you sacrifice a bit of accuracy to display decimals in a more human-= friendly way, i.e. writing =930.3=94 instead of =930.299999999998=94, which= I think most JSON encoders do because otherwise users complain about their= numbers coming out =93wrong=94 or at least =93too long=94. =97Jens (who has written a few JSON encoders)=