Subject: Re: [linux-audio-dev] swh plugins and fixing undenormalize
From: Clemens Ladisch (clemens_AT_ladisch.de)
Date: Thu Jun 24 2004 - 14:20:34 EEST
Steve Harris wrote:
> You can do
>
> y += delta
> y -= delta
>
> but youre at the mercy of the optimiser.
The IEEE standard specifies exactly what happens with denormals, so,
in theory, the compiler must not optimize this away. However,
optimization options for speed often disable strict IEEE
compatibility. (I don't know how gcc's options behave.)
> A C99 safe version of the obove macro (with a bit of extension, to catch
> "P4 denormals") is:
>
> typedef union {
> float f;
> int32_t i;
> } ls_pcast32;
> ...
> v.f = f;
> return (v.i & 0x7f800000) < 0x08000000 ? 0.0f : f;
AFAIK this isn't safe either because the same type aliasing rules
apply to unions, too. The only safe way is to go through char
pointers.
Regards,
Clemens
This archive was generated by hypermail 2b28 : Thu Jun 24 2004 - 14:17:36 EEST