diff options
author | Explorer09 <explorer09@gmail.com> | 2023-08-17 04:21:05 +0800 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2023-08-18 12:52:28 +0200 |
commit | 076b913c7f876ba0489b9751043eeb61aa34680f (patch) | |
tree | 35173363985f959a0e77993b07c3b9fe09a2c1c6 /XUtils.h | |
parent | 93d76fd37627a3594f52afda32092fa3858f28dc (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.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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. */ |