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 http://issues.apache.org/jira/browse/COUCHDB-227 for some links about this issue.

Cheers,
--
Jason Davies

www.jasondavies.com

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<[email protected]> wrote:
Hm, this makes sense. I guess I'll go this way. Thanks

On Tue, Sep 1, 2009 at 12:18 PM, Robert Newson<[email protected] > 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.


Reply via email to