summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorKumar <kumar@onenetbeyond.org>2022-02-19 07:35:04 +0530
committerBenBE <BenBE@geshi.org>2022-02-19 12:21:26 +0100
commit6133cac721f355aec0d6b5581fef90db34305f29 (patch)
tree41a6544910c4b8485aa78374fef8d34f079f1730 /Process.c
parentda653f8148228c2202117cf2cea946b305039552 (diff)
Process: Handle rounding ambiguity between 99.9 and 100.0
Depending upon default behavior of the compiler and floating-point environment, compiler could round down the value between "99.9" and "100.0" to "99.0", instead of rounding it to the nearest value, "100.0". Note: The floating-point environment access and modification is only meaningful when "#pragma STD FENV_ACCESS" is set to "ON"[1]. Otherwise implementation is free to assume that floating-point control modes are always the default. So it would be a good idea to address the rounding ambiguity between "99.9" and "100.0" to become compiler agnostic. [1]: https://en.cppreference.com/w/c/numeric/fenv Credits: @Explorer09, thanks for the suggestion.
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Process.c b/Process.c
index a3118b46..34c66bec 100644
--- a/Process.c
+++ b/Process.c
@@ -741,7 +741,9 @@ void Process_printPercentage(float val, char* buffer, int n, int* attr) {
xSnprintf(buffer, n, "%4.1f ", val);
} else {
*attr = CRT_colors[PROCESS_MEGABYTES];
- xSnprintf(buffer, n, "%4d ", (int)val);
+ if (val < 100.0F)
+ val = 100.0F; // Don't round down and display "val" as "99".
+ xSnprintf(buffer, n, "%4.0f ", val);
}
} else {
*attr = CRT_colors[PROCESS_SHADOW];

© 2014-2024 Faster IT GmbH | imprint | privacy policy