[Date Prev][Date Next][Thread Prev][Thread Next]
- 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 <firstname.lastname@example.org> 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.