guile-user
[Top][All Lists]
Advanced

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

Re: strange behaviour of (floor .)


From: Linas Vepstas
Subject: Re: strange behaviour of (floor .)
Date: Sun, 3 Jan 2010 14:16:43 -0600

2010/1/3 Keith Wright <address@hidden>:

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

Heh. Common misconception.

The core problem, in accounting, is that some divisions
and multiplications are allowed, and others are not. So
for example, you are allowed to divide cost by number of
shares to obtain share price (which is generally a flt pt
number with 12 or more digits of precision). However,
multiplying the number of shares by share price to obtain
a dollar amount is forbiden, because doing so will always
lead to roundoff errors in the cost, leading to all sorts of
accounting imbalances,

Example: bought 300 shares at $12.01/share on June 1st
and bought 500 shares at $12.05/share on June 2nd. What
was the average price paid? How many decimals are needed
to correctly express this average share price? What number
does one get when one computes the average share price
times the total 800 shares bought? How does it compare to
the actual cost paid?

--linas




reply via email to

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