summaryrefslogtreecommitdiffstats
path: root/XUtils.h
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2023-08-17 04:21:05 +0800
committerBenBE <BenBE@geshi.org>2023-08-18 12:52:28 +0200
commit076b913c7f876ba0489b9751043eeb61aa34680f (patch)
tree35173363985f959a0e77993b07c3b9fe09a2c1c6 /XUtils.h
parent93d76fd37627a3594f52afda32092fa3858f28dc (diff)
Compare all percentage fields with compareRealNumbers()
The SPACESHIP_NUMBER() macro does not work well with floating point values that are possible to be NaNs. Change the compare logic of all percentage fields of Process entries to use compareRealNumbers(). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'XUtils.h')
-rw-r--r--XUtils.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/XUtils.h b/XUtils.h
index 68e370b0..fd1087d5 100644
--- a/XUtils.h
+++ b/XUtils.h
@@ -82,6 +82,11 @@ ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size
ATTR_ACCESS3_R(2, 3)
ssize_t full_write(int fd, const void* buf, size_t count);
+/* Compares floating point values for ordering data entries. In this function,
+ NaN is considered "less than" any other floating point value (regardless of
+ sign), and two NaNs are considered "equal" regardless of payload. */
+int compareRealNumbers(double a, double b);
+
/* Computes the sum of all positive floating point values in an array.
NaN values in the array are skipped. The returned sum will always be
nonnegative. */

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