Re: [LAU] building a debian system for audio

From: Karl Hammar <karl@email-addr-hidden>
Date: Wed May 23 2007 - 23:33:12 EEST

On Wed, May 23, 2007 at 10:00:38PM +0200, Fons Adriaensen wrote:
> On Wed, May 23, 2007 at 03:25:26PM -0400, Paul Davis wrote:
>
> > I am very disappointed to hear that the Debian package is using
> > SYSLIBS=1.
>
> This gives me two occasions to show my ignorance instead of just
> the one I was going to post :-)
>
> 1. What does SYSLIBS=1 imply ?

$ apt-get source ardour # current unstable
...
$ find . -type f -print0 | xargs -0 grep SYSLIB
./SConstruct: BoolOption('SYSLIBS', 'USE AT YOUR OWN RISK: CANCELS ALL SUPPORT FROM ARDOUR AUTHORS: Use existing system versions of various libraries instead of internal ones', 0),
./SConstruct:if env['SYSLIBS']:
./debian/rules: SYSLIBS=yes \
$

> 2. (Original reason for this post)
>
> I've been chasing a bug for hours this afternoon, and the conclusion
> is that apparently g++, under some conditions, is not consistent
> in the way it rounds floats to ints in a expression such as
>
> float a, b, x;
> int y;
>
> y = (int)((x - a) * b + 0.5f);
>
> I have this calculation twice, in the same source file. In one
> case it's within a for loop, in the second case it's just a single
> calculation. Both use exactly the same values for a, b, and x, yet
> the result is different (by 1). The value before the cast its something
> like 115.50424, and that gets rounded up in one case and down in the
> other.
>
> This is with -O3. Same with -O2, -O1, but OK without optimisation, and
> also OK if I use -O3 -march=pentium4.
>
> Is this to be expected, and should I use floorf() to avoid it, or is it
> something that should not happen ?

It might not be a bug. You are not guaranteed of the same order of
evaluation of arithmetic expressions in C. If you want that you have
to use FORTRAN or assembler (maybe some other language has it also).

You might get around it with parantheses and/or temporary variables to
force the compiler to do the plusses etc. in a fixed order.

Beware that floating point values (in numerical circles) are considered
to be inexact, also, you might have better luck if you are using
doubles.

Regards,
/Karl

-----------------------------------------------------------------------
Karl Hammar Aspö Data karl@email-addr-hidden
Lilla Aspö 2340 Networks
S-742 94 Östhammar +46 173 140 57 Computers
Sweden +46 70 511 97 84 Consulting
-----------------------------------------------------------------------
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo.cgi/linux-audio-user
Received on Thu May 24 00:15:03 2007

This archive was generated by hypermail 2.1.8 : Thu May 24 2007 - 00:15:03 EEST