projects
/
musl
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
make type of st_dev explicitly dev_t in x86_64 stat.h
[musl]
/
src
/
math
/
roundf.c
1
#include "libm.h"
2
3
float roundf(float x)
4
{
5
union {float f; uint32_t i;} u = {x};
6
int e = u.i >> 23 & 0xff;
7
float_t y;
8
9
if (e >= 0x7f+23)
10
return x;
11
if (u.i >> 31)
12
x = -x;
13
if (e < 0x7f-1) {
14
FORCE_EVAL(x + 0x1p23f);
15
return 0*u.f;
16
}
17
y = (float)(x + 0x1p23f) - 0x1p23f - x;
18
if (y > 0.5f)
19
y = y + x - 1;
20
else if (y <= -0.5f)
21
y = y + x + 1;
22
else
23
y = y + x;
24
if (u.i >> 31)
25
y = -y;
26
return y;
27
}