diff options
Diffstat (limited to 'src/math/ilogb.c')
| -rw-r--r-- | src/math/ilogb.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/math/ilogb.c b/src/math/ilogb.c index 0d826e04..d1295815 100644 --- a/src/math/ilogb.c +++ b/src/math/ilogb.c @@ -1,9 +1,18 @@ # define TGSOURCE "ilogb.c" #include "_tgmath.h" #include <math.h> +#include "limits.h" +#include "fenv.h" -TYPE TGFN(ilogb)(TYPE x) +int TGFN(ilogb)(TYPE x) { + switch (fpclassify(x)) { + case FP_ZERO: feraiseexcept(FE_INVALID); return FP_ILOGB0; + case FP_INFINITE: feraiseexcept(FE_INVALID); return INT_MAX; + case FP_NAN: feraiseexcept(FE_INVALID); return FP_ILOGBNAN; + default: break; + } + return x; } |
