lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 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.

If you use Lua integers and thousandths of cents as your unit, you will
be able to represent up to ~90 trillion USD. That seems enough for most
uses.

-- Roberto