aboutsummaryrefslogtreecommitdiffstats
path: root/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/printf.c b/printf.c
index e9d714a..ed2b3ba 100644
--- a/printf.c
+++ b/printf.c
@@ -363,11 +363,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
if (prec == 0U) {
diff = value - (double)whole;
- if (diff > 0.5) {
- // greater than 0.5, round up, e.g. 1.6 -> 2
- ++whole;
- }
- else if ((diff == 0.5) && (whole & 1)) {
+ if ((!(diff < 0.5) || (diff > 0.5)) && (whole & 1)) {
// exactly 0.5 and ODD, then round up
// 1.5 -> 2, but 2.5 -> 2
++whole;