[linux-audio-dev] Traps in floating point code

Ruben van Royen rvroyen at guidedbees.com
Thu Jul 1 08:37:33 UTC 2004


The problem is that the rounding mode affects all floating point operations, 
such as multiply and divide. And normally you must do rounding and not 
truncation. Thus changing the mode will change the results, and a compiler is 
not allowed to do that. 
Only in very specific cases, such as a loop that converts an array float 
values to integers, where the truncation is the only floating point operation 
in the loop, is the compiler allowed to do the mode settings outside the 
loop. But I'm not sure if gcc does this.

Ruben

On Thursday 01 July 2004 10:14, Steve Harris wrote:
> On Wed, Jun 30, 2004 at 11:09:28 +0200, Tim Goetze wrote:
> > so if you want quick fractional sample lookups, the best option on x86
> > i see is to manually "fldcw" before and after your sample loop, and
> > use lrintf() or "fistpl" directly to obtain integer indices inside
> > the loop.
>
> I wonder why gcc doenst spot that?
>
> - Steve



More information about the Linux-audio-dev mailing list