From 9ca11f20c6106cb5ce8ea0fc44888280ce772775 Mon Sep 17 00:00:00 2001
From: Jeff Bezanson <jeff.bezanson@gmail.com>
Date: Thu, 19 Dec 2013 17:52:23 -0500
Subject: [PATCH] updates to s_round.c from FreeBSD

---
 src/s_round.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/s_round.c b/src/s_round.c
index ec758fc..d1250b4 100644
--- a/src/s_round.c
+++ b/src/s_round.c
@@ -34,19 +34,21 @@ DLLEXPORT double
 round(double x)
 {
 	double t;
+	uint32_t hx;
 
-	if (!isfinite(x))
-		return (x);
+	GET_HIGH_WORD(hx, x);
+	if ((hx & 0x7fffffff) == 0x7ff00000)
+		return (x + x);
 
-	if (x >= 0.0) {
+	if (!(hx & 0x80000000)) {
 		t = floor(x);
 		if (t - x <= -0.5)
-			t += 1.0;
+			t += 1;
 		return (t);
 	} else {
 		t = floor(-x);
 		if (t + x <= -0.5)
-			t += 1.0;
+			t += 1;
 		return (-t);
 	}
 }