Back to index

glibc  2.9
Classes | Typedefs | Functions | Variables
e_sqrtl.c File Reference
#include <math_private.h>

Go to the source code of this file.

Classes

union  mynumber

Typedefs

typedef unsigned int int4

Functions

long double __ieee754_sqrtl (long double x)

Variables

static const mynumber t512 = {{0x5ff00000, 0x00000000, 0x00000000, 0x00000000 }}
static const mynumber tm256 = {{0x2ff00000, 0x00000000, 0x00000000, 0x00000000 }}
static const double two54 = 1.80143985094819840000e+16
static const double twom54 = 5.55111512312578270212e-17

Class Documentation

union mynumber

Definition at line 32 of file mydefs.h.

Class Members
double d
int4 i
double x
long double x

Typedef Documentation

typedef unsigned int int4

Definition at line 38 of file e_sqrtl.c.


Function Documentation

long double __ieee754_sqrtl ( long double  x)

Definition at line 53 of file e_sqrtl.c.

{
  static const long double big = 134217728.0, big1 = 134217729.0;
  long double t,s,i;
  mynumber a,c;
  int4 k, l, m;
  int n;
  double d;

  a.x=x;
  k=a.i[0] & 0x7fffffff;
  /*----------------- 2^-1022  <= | x |< 2^1024  -----------------*/
  if (k>0x000fffff && k<0x7ff00000) {
    if (x < 0) return (big1-big1)/(big-big);
    l = (k&0x001fffff)|0x3fe00000;
    if (((a.i[2] & 0x7fffffff) | a.i[3]) != 0) {
      n = (int) ((l - k) * 2) >> 21;
      m = (a.i[2] >> 20) & 0x7ff;
      if (m == 0) {
       a.d[1] *= two54;
       m = ((a.i[2] >> 20) & 0x7ff) - 54;
      }
      m += n;
      if (m > 0)
       a.i[2] = (a.i[2] & 0x800fffff) | (m << 20);
      else if (m <= -54) {
       a.i[2] &= 0x80000000;
       a.i[3] = 0;
      } else {
       m += 54;
       a.i[2] = (a.i[2] & 0x800fffff) | (m << 20);
       a.d[1] *= twom54;
      }
    }
    a.i[0] = l;
    s = a.x;
    d = __ieee754_sqrt (a.d[0]);
    c.i[0] = 0x20000000+((k&0x7fe00000)>>1);
    c.i[1] = 0;
    c.i[2] = 0;
    c.i[3] = 0;
    i = d;
    t = 0.5L * (i + s / i);
    i = 0.5L * (t + s / t);
    return c.x * i;
  }
  else {
    if (k>=0x7ff00000) {
      if (a.i[0] == 0xfff00000 && a.i[1] == 0)
       return (big1-big1)/(big-big); /* sqrt (-Inf) = NaN.  */
      return x; /* sqrt (NaN) = NaN, sqrt (+Inf) = +Inf.  */
    }
    if (x == 0) return x;
    if (x < 0) return (big1-big1)/(big-big);
    return tm256.x*__ieee754_sqrtl(x*t512.x);
  }
}

Here is the call graph for this function:


Variable Documentation

const mynumber t512 = {{0x5ff00000, 0x00000000, 0x00000000, 0x00000000 }} [static]

Definition at line 42 of file e_sqrtl.c.

const mynumber tm256 = {{0x2ff00000, 0x00000000, 0x00000000, 0x00000000 }} [static]

Definition at line 43 of file e_sqrtl.c.

const double two54 = 1.80143985094819840000e+16 [static]

Definition at line 45 of file e_sqrtl.c.

const double twom54 = 5.55111512312578270212e-17 [static]

Definition at line 46 of file e_sqrtl.c.