Skip to content

Commit 9ca11f2

Browse files
committed
updates to s_round.c from FreeBSD
1 parent 3566e32 commit 9ca11f2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/s_round.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,21 @@ DLLEXPORT double
3434
round(double x)
3535
{
3636
double t;
37+
uint32_t hx;
3738

38-
if (!isfinite(x))
39-
return (x);
39+
GET_HIGH_WORD(hx, x);
40+
if ((hx & 0x7fffffff) == 0x7ff00000)
41+
return (x + x);
4042

41-
if (x >= 0.0) {
43+
if (!(hx & 0x80000000)) {
4244
t = floor(x);
4345
if (t - x <= -0.5)
44-
t += 1.0;
46+
t += 1;
4547
return (t);
4648
} else {
4749
t = floor(-x);
4850
if (t + x <= -0.5)
49-
t += 1.0;
51+
t += 1;
5052
return (-t);
5153
}
5254
}

0 commit comments

Comments
 (0)