__builtin_isnormal question
Andrew Pinski
pinskia@gmail.com
Mon Jun 4 20:47:00 GMT 2018
On Mon, Jun 4, 2018 at 1:44 PM Steve Ellcey <sellcey@cavium.com> wrote:
>
> Is there a bug in __builtin_isnormal or am I just confused as to what it
> means? There doesn't seem to be any actual definition/documentation for
> the function. __builtin_isnormal(0.0) is returning false. That seems
> wrong to me, 0.0 is a normal (as opposed to a denormalized) number isn't
> it? Or is zero special?
I think it is just the builtin version of the standard C/C++ function
isnormal which has the following definition:
Determines if the given floating point number arg is normal, i.e. is
neither zero, subnormal, infinite, nor NaN. The macro returns an
integral value.
--- CUT ---
Which means zero is special :).
Thanks,
Andrew
>
> Steve Ellcey
> sellcey@cavium.com
>
> #include <math.h>
> #include <stdio.h>
> #include <values.h>
> int main()
> {
> double x;
> x = 0.0;
> printf("%e %e %e\n", x, DBL_MIN, DBL_MAX);
> printf("normal is %s\n", __builtin_isnormal(x) ? "TRUE" : "FALSE");
> x = 1.0;
> printf("%e %e %e\n", x, DBL_MIN, DBL_MAX);
> printf("normal is %s\n", __builtin_isnormal(x) ? "TRUE" : "FALSE");
> return 0;
> }
>
> % gcc x.c -o x
> % ./x
> 0.000000e+00 2.225074e-308 1.797693e+308
> normal is FALSE
> 1.000000e+00 2.225074e-308 1.797693e+308
> normal is TRUE
More information about the Gcc
mailing list