SDL  2.0
s_scalbn.c File Reference
#include "math_libm.h"
#include "math_private.h"
#include <limits.h>
+ Include dependency graph for s_scalbn.c:

Go to the source code of this file.

Functions

double scalbln (double x, long n)
 libm_hidden_def (scalbln)

Variables

static const double two54 = 1.80143985094819840000e+16
static const double twom54 = 5.55111512312578270212e-17
static const double huge = 1.0e+300
static const double tiny = 1.0e-300

Function Documentation

libm_hidden_def ( scalbln  )

Definition at line 62 of file s_scalbn.c.

References scalbln().

{
return scalbln(x, n);
}
double scalbln ( double  x,
long  n 
)

Definition at line 29 of file s_scalbn.c.

References copysign(), EXTRACT_WORDS, GET_HIGH_WORD, huge, k, SET_HIGH_WORD, tiny, two54, and twom54.

Referenced by libm_hidden_def().

{
int32_t k, hx, lx;
EXTRACT_WORDS(hx, lx, x);
k = (hx & 0x7ff00000) >> 20; /* extract exponent */
if (k == 0) { /* 0 or subnormal x */
if ((lx | (hx & 0x7fffffff)) == 0)
return x; /* +-0 */
x *= two54;
k = ((hx & 0x7ff00000) >> 20) - 54;
}
if (k == 0x7ff)
return x + x; /* NaN or Inf */
k = k + n;
if (k > 0x7fe)
return huge * copysign(huge, x); /* overflow */
if (n < -50000)
return tiny * copysign(tiny, x); /* underflow */
if (k > 0) { /* normal result */
SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
return x;
}
if (k <= -54) {
if (n > 50000) /* in case integer overflow in n+k */
return huge * copysign(huge, x); /* overflow */
return tiny * copysign(tiny, x); /* underflow */
}
k += 54; /* subnormal result */
SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
return x * twom54;
}

Variable Documentation

const double huge = 1.0e+300
static

Definition at line 26 of file s_scalbn.c.

Referenced by scalbln().

const double tiny = 1.0e-300
static

Definition at line 27 of file s_scalbn.c.

Referenced by scalbln().

const double two54 = 1.80143985094819840000e+16
static

Definition at line 24 of file s_scalbn.c.

Referenced by scalbln().

const double twom54 = 5.55111512312578270212e-17
static

Definition at line 25 of file s_scalbn.c.

Referenced by scalbln().