summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openbsd-compat/fmt_scaled.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c
index f68f24123..2f76ef931 100644
--- a/openbsd-compat/fmt_scaled.c
+++ b/openbsd-compat/fmt_scaled.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: fmt_scaled.c,v 1.16 2017/03/16 02:40:46 dtucker Exp $ */ 1/* $OpenBSD: fmt_scaled.c,v 1.17 2018/05/14 04:39:04 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. 4 * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@@ -246,12 +246,15 @@ fmt_scaled(long long number, char *result)
246 246
247 fract = (10 * fract + 512) / 1024; 247 fract = (10 * fract + 512) / 1024;
248 /* if the result would be >= 10, round main number */ 248 /* if the result would be >= 10, round main number */
249 if (fract == 10) { 249 if (fract >= 10) {
250 if (number >= 0) 250 if (number >= 0)
251 number++; 251 number++;
252 else 252 else
253 number--; 253 number--;
254 fract = 0; 254 fract = 0;
255 } else if (fract < 0) {
256 /* shouldn't happen */
257 fract = 0;
255 } 258 }
256 259
257 if (number == 0) 260 if (number == 0)