Back to index

glibc  2.9
Functions
s_fpclassifyl.c File Reference
#include <math.h>
#include "math_private.h"
#include <math_ldbl_opt.h>

Go to the source code of this file.

Functions

int ___fpclassifyl (long double x)
 long_double_symbol (libm, ___fpclassifyl, __fpclassifyl)

Function Documentation

int ___fpclassifyl ( long double  x)

Definition at line 46 of file s_fpclassifyl.c.

{
  u_int64_t hx, lx;
  int retval = FP_NORMAL;

  GET_LDOUBLE_WORDS64 (hx, lx, x);
  if ((hx & 0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) {
      /* +/-NaN or +/-Inf */
      if (hx & 0x000fffffffffffffULL) {
         /* +/-NaN */
         retval = FP_NAN;
      } else {
         retval = FP_INFINITE;
      }
  } else {
      /* +/-zero or +/- normal or +/- denormal */
      if (hx & 0x7fffffffffffffffULL) {
         /* +/- normal or +/- denormal */
         if ((hx & 0x7ff0000000000000ULL) > 0x0360000000000000ULL) {
             /* +/- normal */
             retval = FP_NORMAL;
         } else {
             if ((hx & 0x7ff0000000000000ULL) == 0x0360000000000000ULL) {
                if ((lx & 0x7fffffffffffffff)    /* lower is non-zero */
                && ((lx^hx) & 0x8000000000000000ULL)) { /* and sign differs */
                    /* +/- denormal */
                    retval = FP_SUBNORMAL;
                } else {
                    /* +/- normal */
                    retval = FP_NORMAL;
                }
             } else {
                /* +/- denormal */
                retval = FP_SUBNORMAL;
             }
         }
      } else {
         /* +/- zero */
         retval = FP_ZERO;
      }
  }

  return retval;
}