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

Maarten de Boer mdeboer at iua.upf.es
Mon Jun 28 10:23:37 UTC 2004


Hi Erik,

Depending on the ranges of your increment, and the accuracy you
want to obtain, you might consider doing this with integers only.

Maarten

> The fix in this case was this:
> 
>     for (;;)
>     {   
>         /* Bunch of other code. */
> 
> 	fractional += increment ;
>         rem = fmod (fractional, 1.0);   /* floating point modulus */
>         integer += lrint (round (fractional - rem));
>         fractional = rem;
>         }



More information about the Linux-audio-dev mailing list