projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
add legacy sys/ttydefaults.h header
[oweals/musl.git]
/
src
/
math
/
scalbn.c
1
#include "libm.h"
2
3
double scalbn(double x, int n)
4
{
5
double scale;
6
7
if (n > 1023) {
8
x *= 0x1p1023;
9
n -= 1023;
10
if (n > 1023) {
11
x *= 0x1p1023;
12
n -= 1023;
13
if (n > 1023) {
14
STRICT_ASSIGN(double, x, x * 0x1p1023);
15
return x;
16
}
17
}
18
} else if (n < -1022) {
19
x *= 0x1p-1022;
20
n += 1022;
21
if (n < -1022) {
22
x *= 0x1p-1022;
23
n += 1022;
24
if (n < -1022) {
25
STRICT_ASSIGN(double, x, x * 0x1p-1022);
26
return x;
27
}
28
}
29
}
30
INSERT_WORDS(scale, (uint32_t)(0x3ff+n)<<20, 0);
31
STRICT_ASSIGN(double, x, x * scale);
32
return x;
33
}