We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3566e32 commit 9ca11f2Copy full SHA for 9ca11f2
src/s_round.c
@@ -34,19 +34,21 @@ DLLEXPORT double
34
round(double x)
35
{
36
double t;
37
+ uint32_t hx;
38
- if (!isfinite(x))
39
- return (x);
+ GET_HIGH_WORD(hx, x);
40
+ if ((hx & 0x7fffffff) == 0x7ff00000)
41
+ return (x + x);
42
- if (x >= 0.0) {
43
+ if (!(hx & 0x80000000)) {
44
t = floor(x);
45
if (t - x <= -0.5)
- t += 1.0;
46
+ t += 1;
47
return (t);
48
} else {
49
t = floor(-x);
50
if (t + x <= -0.5)
51
52
return (-t);
53
}
54
0 commit comments