[Top][All Lists]

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

Re: strange behaviour of (floor .)

From: Keith Wright
Subject: Re: strange behaviour of (floor .)
Date: Sun, 3 Jan 2010 15:51:28 -0500

> From: Thien-Thi Nguyen <address@hidden>
> Note, however, that usually it is better (less fiddly)
> to represent monetary values as integers.

Yes, always represent money as an integer number
of cents and put in a decimal point when you
print.  That is, "$16.98" is produced by
something like (money->string 1698).  This
is true for ALL languages, although it is
especially easy to do in Scheme with its
large integer arithmetic.

If you will need large integers in some other
language, take the time to implement them.  You do
NOT want to lose precision by using floating
point.  "Fiddly" is the least of your worries;
you might go to jail for round-off error.

You do not want to finish this conversation:

CFO: What happened to the $12,345.67?
You: Well, you see sir, IEEE floating point...

   -- Keith

reply via email to

[Prev in Thread] Current Thread [Next in Thread]