[PATCH 2/2] Fix missed "+0.5" rounding - use rint() instead

Linus Torvalds torvalds at linux-foundation.org
Sun Feb 16 11:52:32 UTC 2014


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sun, 16 Feb 2014 11:38:47 -0800
Subject: [PATCH 2/2] Fix missed "+0.5" rounding - use rint() instead

In commit 23baf20f569f (Use "rint()" instead of rounding manually with
"+ 0.5") I had missed this one remaining place where we rounded things
by adding "+0.5" and then truncated.

Fix that up.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

I'm still thinking about better file formats and backup, but haven't come 
up with anything that I'm actually happy about. In the meantime I'm 
dicking around and sending out these silly small cleanups.

 dive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dive.c b/dive.c
index edcb130f4ec7..e4fe8606c9ae 100644
--- a/dive.c
+++ b/dive.c
@@ -513,7 +513,7 @@ static void match_standard_cylinder(cylinder_type_t *type)
 	default:
 		return;
 	}
-	len = snprintf(buffer, sizeof(buffer), fmt, (int) (cuft+0.5));
+	len = snprintf(buffer, sizeof(buffer), fmt, rint(cuft));
 	p = malloc(len+1);
 	if (!p)
 		return;
-- 
1.9.0.rc3



More information about the subsurface mailing list