lua-users home
lua-l archive

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


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.


Sent from my Samsung device over Bell's LTE network.


-------- Original message --------
From: Matthias Kluwe <mkluwe@gmail.com>
Date: 09-05-2016 9:34 AM (GMT-05:00)
To: Lua mailing list <lua-l@lists.lua.org>
Subject: Re: Currency representation in Lua

Hi!

Am 05.09.2016 03:40 schrieb "Diogo Mildenberger" <diogo.milde@gmail.com>:

> Has someone any experience to share about implementing a system that deals with currency values? I have already been bitten by the problems described in http://floating-point-gui.de/ and I want to find a better way.

Before jumping to conclusions, I'd like to know what proble you actually encountered (besides from "my numbers don't add up").

Regards,
Matthias