From cf8c01845e67e9cee6d70917273ab8060cc90372 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 13 Aug 2024 03:25:13 -0400 Subject: Fix issue with integer comparisons --- builtins/integers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtins/integers.c b/builtins/integers.c index de4c9b78..6a976d42 100644 --- a/builtins/integers.c +++ b/builtins/integers.c @@ -58,24 +58,24 @@ public CORD Int$as_text(const Int_t *i, bool colorize, const TypeInfo *type) { public int32_t Int$compare(const Int_t *x, const Int_t *y, const TypeInfo *type) { (void)type; - if (__builtin_expect(((x->small & y->small) & 1) == 0, 0)) + if (__builtin_expect(((x->small | y->small) & 1) == 0, 0)) return mpz_cmp(*x->big, *y->big); return (x->small > y->small) - (x->small < y->small); } public int32_t Int$compare_value(const Int_t x, const Int_t y) { - if (__builtin_expect(((x.small & y.small) & 1) == 0, 0)) + if (__builtin_expect(((x.small | y.small) & 1) == 0, 0)) return mpz_cmp(*x.big, *y.big); return (x.small > y.small) - (x.small < y.small); } public bool Int$equal(const Int_t *x, const Int_t *y, const TypeInfo *type) { (void)type; - return x->small == y->small || (__builtin_expect(((x->small & y->small) & 1) == 0, 0) && mpz_cmp(*x->big, *y->big) == 0); + return x->small == y->small || (__builtin_expect(((x->small | y->small) & 1) == 0, 0) && mpz_cmp(*x->big, *y->big) == 0); } public bool Int$equal_value(const Int_t x, const Int_t y) { - return x.small == y.small || (__builtin_expect(((x.small & y.small) & 1) == 0, 0) && mpz_cmp(*x.big, *y.big) == 0); + return x.small == y.small || (__builtin_expect(((x.small | y.small) & 1) == 0, 0) && mpz_cmp(*x.big, *y.big) == 0); } public uint32_t Int$hash(const Int_t *x, const TypeInfo *type) { -- cgit v1.2.3