Using trunc function in Erlang

Andrae Muys andrae@REDACTED
Tue Jan 3 02:26:57 CET 2006


On 31/12/2005, at 5:50 AM, Erlang Questions wrote:

> I was afraid about that.
> Unfortunately, these numbers represent money in my application :o(
>

Never, under any circumstance, without exception, ever use floating  
point to represent money.

You can use integers, fixed point, decimals, rationals or improper  
fractions.  All provide various tradeoffs, but all are infinitely  
superior to floating point.

Worse, as people have already mentioned, there can be legal  
ramifications as there are unavoidable errors in floating point  
calculations that cannot always be reconciled with statutory rounding  
requirements.

Andrae Muys (who learnt this lesson the hard way, and once had to  
spend several painful months converting a financial application from  
floating point to decimal)

-- 
Andrae Muys
andrae@REDACTED
Principal Kowari Consultant
Netymon Pty Ltd




More information about the erlang-questions mailing list