diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-31 15:14:07 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-31 15:14:07 -0500 |
| commit | 41f92837bebae1de783dc7f4a8f880011c72757c (patch) | |
| tree | 4730711a7c13c19c135d0432be4d1fe9b34c1f77 /src/stdlib | |
| parent | 1f13fa92a87bec65d1760266b108a5485bc14c7a (diff) | |
| parent | dbae987f1fb54da795185a03f4c00d56a639f8cd (diff) | |
Merge branch 'dev' into static-dependencies
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/bigint.c | 4 | ||||
| -rw-r--r-- | src/stdlib/bytes.c | 2 | ||||
| -rw-r--r-- | src/stdlib/intX.c.h | 2 | ||||
| -rw-r--r-- | src/stdlib/numX.c.h | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/src/stdlib/bigint.c b/src/stdlib/bigint.c index d47dfee8..11270848 100644 --- a/src/stdlib/bigint.c +++ b/src/stdlib/bigint.c @@ -140,7 +140,9 @@ CONSTFUNC Int_t Int$clamped(Int_t x, Int_t low, Int_t high) { public CONSTFUNC bool Int$is_between(const Int_t x, const Int_t low, const Int_t high) { - return Int$compare_value(low, x) <= 0 && Int$compare_value(x, high) <= 0; + int32_t low_cmp = Int$compare_value(x, low); + int32_t high_cmp = Int$compare_value(x, high); + return (low_cmp >= 0 && high_cmp <= 0) || (low_cmp <= 0 && high_cmp >= 0); } public diff --git a/src/stdlib/bytes.c b/src/stdlib/bytes.c index 2b2a6507..25f95de1 100644 --- a/src/stdlib/bytes.c +++ b/src/stdlib/bytes.c @@ -32,7 +32,7 @@ PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo public CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) { - return low <= x && x <= high; + return (low <= x && x <= high) || (high <= x && x <= low); } public diff --git a/src/stdlib/intX.c.h b/src/stdlib/intX.c.h index 19f838d7..e6153ac9 100644 --- a/src/stdlib/intX.c.h +++ b/src/stdlib/intX.c.h @@ -119,7 +119,7 @@ PUREFUNC bool NAMESPACED(equal)(const void *x, const void *y, const TypeInfo_t * } public CONSTFUNC bool NAMESPACED(is_between)(const INT_T x, const INT_T low, const INT_T high) { - return low <= x && x <= high; + return (low <= x && x <= high) || (high <= x && x <= low); } public CONSTFUNC INT_T NAMESPACED(clamped)(INT_T x, INT_T min, INT_T max) { diff --git a/src/stdlib/numX.c.h b/src/stdlib/numX.c.h index 2d652ebe..bef78c5b 100644 --- a/src/stdlib/numX.c.h +++ b/src/stdlib/numX.c.h @@ -193,7 +193,7 @@ CONSTFUNC NUM_T NAMESPACED(mix)(NUM_T amount, NUM_T x, NUM_T y) { public CONSTFUNC bool NAMESPACED(is_between)(const NUM_T x, const NUM_T low, const NUM_T high) { - return low <= x && x <= high; + return (low <= x && x <= high) || (high <= x && x <= low); } public CONSTFUNC NUM_T NAMESPACED(clamped)(NUM_T x, NUM_T low, NUM_T high) { |
