diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-03-04 19:05:44 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-03-08 19:18:58 +0100 |
commit | 160b971f6cf9e2b92eb07b8e6a56e3d5a99dc9ea (patch) | |
tree | ea38fd71573ec09f90faa5185995e994a0ef8020 | |
parent | 5aceeaa6b9fbfcf80ac4c09474a956f9929bf863 (diff) |
value: ensure proper result of relational NaN comparison
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | value.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -290,6 +290,10 @@ uc_cmp(int how, json_object *v1, json_object *v2) d1 = (t1 == json_type_double) ? d1 : (double)n1; d2 = (t2 == json_type_double) ? d2 : (double)n2; + /* all comparison results except `!=` involving NaN are false */ + if (isnan(d1) || isnan(d2)) + return (how == TK_NE); + if (d1 == d2) delta = 0; else if (d1 < d2) |