# [ardour-dev] Some summers are better than others?

Sun Jan 15 15:38:10 PST 2006

On Sun, Jan 15, 2006 at 11:30:42PM +0100, Samuel TRACOL wrote:

> >If the format is floating point there are indeed different ways of doing this
> >and they will produce different results numerically.
>
> Can you explain it a bit more ? or even give links about some litterature to read ?

It comes down to the simple fact that the associativity law of addition is
not preserved in floating point format. This is well know by people who
develop scientific numerical software, and they use various clever tricks
to work around the problem.

Let's take a simple example of adding 3 samples:

A =  0.50000000
B =  0.00000002
C = -0.49990000

If we first add B to A, then C to the sum, then the precision of
the result will be much impaired because B is very small compared
to A, and most of it significant bits will be lost in the first

If OTOH, we first add C to A, giving 0.0001, and then add B, more
of its significant bits will be preserved. So one strategy consist
of first sorting by decreasing absolute value, and then add.

Depending on how things are implemented, things may be less serious,
e.g. intermediate results may be preserved in higher precision than
the final value. But ensuring this requires some effort from the
programmer. In most cases he/she just doesn't know exactly how
something is calculated.

Now how significant this is in an audio context is an interesting
question. How often do you mix channels that (nearly) cancel each
other ? Unless you do, the error on the sum will be swamped by
noise - even the very best hardware doesn't give you much more than
20 bits.

--
FA