lua-users home
lua-l archive

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


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


If you are writing financial programs for e.g. mark-to-model present value, risk and so forth, it’s quite typical for these do deal with doubles only [across huge swathes of systems in banks and investment funds].

If you are writing an accounting or taxation program, you’ll also need to cope with specific rounding schemes imposed externally in addition to the advice on fixed point given  here, and should think like an accountant (double entry et al) so that you don’t introduce other forms of gap,  e.g. not doing
new_balance,old_balance=balance/3,2*balance/3

Regards

Scott