[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Currency representation in Lua
- From: Coda Highland <chighland@...>
- Date: Mon, 5 Sep 2016 14:27:16 -0700
On Mon, Sep 5, 2016 at 2:07 PM, Doug <doug16k@gmail.com> wrote:
> Double precision floating point can represent all integers up to +-2^53
> exactly. You should represent your amounts as the smallest unit of currency,
> such as cents. Also be sure to round results to the nearest integer after
> all multiplications and divisions. Additions and subtraction of integer
> values will be exact.
Nitpick: The smallest unit of currency may not actually be a unit of
legal tender; as discussed elsewhere in the thread, the smallest unit
might be for example tenths of a cent.
/s/ Adam