Back to index

glibc  2.9
Functions
mpn2ldbl.c File Reference
#include "gmp.h"
#include "gmp-impl.h"
#include <ieee754.h>
#include <float.h>
#include <math.h>

Go to the source code of this file.

Functions

long double __mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)

Function Documentation

long double __mpn_construct_long_double ( mp_srcptr  frac_ptr,
int  expt,
int  sign 
)

Definition at line 31 of file mpn2ldbl.c.

{
  union ieee854_long_double u;

  u.ieee.negative = sign;
  u.ieee.exponent = expt + IEEE854_LONG_DOUBLE_BIAS;
#if BITS_PER_MP_LIMB == 32
  u.ieee.mantissa3 = frac_ptr[0];
  u.ieee.mantissa2 = frac_ptr[1];
  u.ieee.mantissa1 = frac_ptr[2];
  u.ieee.mantissa0 = frac_ptr[3] & (((mp_limb_t) 1
                                 << (LDBL_MANT_DIG - 96)) - 1);
#elif BITS_PER_MP_LIMB == 64
  u.ieee.mantissa3 = frac_ptr[0] & (((mp_limb_t) 1 << 32) - 1);
  u.ieee.mantissa2 = frac_ptr[0] >> 32;
  u.ieee.mantissa1 = frac_ptr[1] & (((mp_limb_t) 1 << 32) - 1);
  u.ieee.mantissa0 = (frac_ptr[1] >> 32) & (((mp_limb_t) 1
                                        << (LDBL_MANT_DIG - 96)) - 1);
#else
  #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
#endif

  return u.d;
}