[LAD] Floating point Denormals: C++ and Waf

Charles Henry czhenry at gmail.com
Thu Aug 2 15:13:59 UTC 2012


Hi Martin,

Can I pick your brain on how this works?

My biggest question is why to use the typedef__u32__attribute__ line
inside an inline function.  Don't you only have to do this once?  If
so, wouldn't you place that line outside the function?

On Thu, Aug 2, 2012 at 7:39 AM, Martin Homuth-Rosemann
<linuxaudio at cryptomys.de> wrote:

> static inline float daz( float f )

If we remove the "static" scope of this function, could we make a
header and re-use this code efficiently?

> {
>   // define an aliasing type to perform a "reinterpret cast"
>   typedef __u32 __attribute__ (( __may_alias__ )) u32bit;
>   if ( *( (u32bit*)&f ) & 0x7F000000 ) // E > 1 : normal.

Is there a 64-bit version of the same?  This appears to work with a
32-bit unsigned int as a pointer, meaning that it's applicable to
32-bits.  How does a "reinterpret cast" work?

What this does is check the exponent is non-zero, right?  Doesn't this
also depend on the mantissa?  for example, if the mantissa is 2^24-1
and the exponent is zero, is that number still a denormal?

>     return f;
>   else // E <= 1 : zero or _almost_ denormal
>        // (may become denormal with next operation)
>     return 0.0;
> }
>
> Ciao, Martin

Thanks for the code--any further explanation would be enlightening.

Chuck



More information about the Linux-audio-dev mailing list