[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Currency representation in Lua
- From: Doug <doug16k@...>
- Date: Mon, 05 Sep 2016 17:07:43 -0400
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 <email@example.com>
Date: 09-05-2016 9:34 AM (GMT-05:00)
To: Lua mailing list <firstname.lastname@example.org>
Subject: Re: Currency representation in Lua
Am 05.09.2016 03:40 schrieb "Diogo Mildenberger" <email@example.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").