couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Davies <>
Subject Re: Is fixed precision arithmetic possible in couchdb python?
Date Tue, 01 Sep 2009 12:58:24 GMT
Also, if you are worried about loss of precision with large integers  
(with more than 15 digits) you should use a JavaScript port of  
BigInteger (or BigDecimal) for calculations and store the numbers as  
strings.  I'm successfully using BigDecimal for financial calculations  
at the moment.  It's probably overkill for most people but it works.   
See also for some  
links about this issue.

Jason Davies

On 1 Sep 2009, at 13:47, Paul Davis wrote:

> Noah Slater had a post quite some time ago where he admonished the use
> of floats for money. He said to always use two integers and figure out
> the mat yourself. With floats is only a matter of time before you
> start missing pennies.
> It stuck with me so I thought I'd mention it.
> Paul
> On Tue, Sep 1, 2009 at 5:27 AM, Metin Akat<>  
> wrote:
>> Hm, this makes sense. I guess I'll go this way. Thanks
>> On Tue, Sep 1, 2009 at 12:18 PM, Robert Newson< 
>> > wrote:
>>> Multiply your numbers by the amount of precision you need and use
>>> integers (*1000 for 3 d.p)? Using floating point to store money
>>> amounts seems fraught with rounding errors.
>>> B.

View raw message