projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
add __sigsetjmp ABI-compat alias for sigsetjmp
[oweals/musl.git]
/
src
/
math
/
rint.c
1
#include <math.h>
2
#include <stdint.h>
3
4
double rint(double x)
5
{
6
union {double f; uint64_t i;} u = {x};
7
int e = u.i>>52 & 0x7ff;
8
int s = u.i>>63;
9
double_t y;
10
11
if (e >= 0x3ff+52)
12
return x;
13
if (s)
14
y = (double)(x - 0x1p52) + 0x1p52;
15
else
16
y = (double)(x + 0x1p52) - 0x1p52;
17
if (y == 0)
18
return s ? -0.0 : 0;
19
return y;
20
}