Back to index

glibc  2.9
Functions
s_frexpl.c File Reference
#include <math.h>

Go to the source code of this file.

Functions

long double __frexpl (long double value, int *expptr)

Function Documentation

long double __frexpl ( long double  value,
int expptr 
)

Definition at line 22 of file s_frexpl.c.

{
  long double mantissa, exponent;
  int iexponent;
  unsigned long fpsr;

  __asm ("ftst%.x %1\n"
        "fmove%.l %/fpsr, %0"
        : "=dm" (fpsr) : "f" (value));
  if (fpsr & (7 << 24))
    {
      /* Not finite or zero.  */
      *expptr = 0;
      return value;
    }
  __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value));
  iexponent = (int) exponent + 1;
  *expptr = iexponent;
  /* Unnormalized numbers must be handled specially, otherwise fscale
     results in overflow.  */
  if (iexponent <= -16384)
    {
      value *= 0x1p16383L;
      iexponent += 16383;
    }
  else if (iexponent >= 16384)
    {
      value *= 0x1p-16383L;
      iexponent -= 16383;
    }

  __asm ("fscale%.l %2, %0"
        : "=f" (mantissa)
        : "0" (value), "dmi" (-iexponent));
  return mantissa;
}