diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 14:13:02 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 14:13:02 -0400 |
| commit | 5a0502bdf5da0b1cdb91fb1d0dfa08b4c4a4db0b (patch) | |
| tree | d461fec6453e8e99cefabd712ee27091528731ea /builtins | |
| parent | 148782e61ba4efbf2981e7d9e18279e92054e149 (diff) | |
Fix some edge cases
Diffstat (limited to 'builtins')
| -rw-r--r-- | builtins/integers.c | 3 | ||||
| -rw-r--r-- | builtins/integers.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/builtins/integers.c b/builtins/integers.c index 776fdc3d..53e38aab 100644 --- a/builtins/integers.c +++ b/builtins/integers.c @@ -23,7 +23,8 @@ public void Int$init_random(long seed) public Int_t Int$from_i64(int64_t i) { - if (i == (int32_t)i) return (Int_t){.small=(i*4)+1}; + int64_t z = i<<2; + if (z == (int32_t)z) return (Int_t){.small=z+1}; mpz_t result; mpz_init_set_si(result, i); return Int$from_mpz(result); diff --git a/builtins/integers.h b/builtins/integers.h index f9051ff5..5566c549 100644 --- a/builtins/integers.h +++ b/builtins/integers.h @@ -60,7 +60,7 @@ Range_t Int$to(Int_t from, Int_t to); Int_t Int$from_text(CORD text); Int_t Int$abs(Int_t x); -#define BIGGEST_SMALL_INT ((1<<30)-1) +#define BIGGEST_SMALL_INT (536870911) #define Int$from_mpz(mpz) (\ mpz_cmpabs_ui(mpz, BIGGEST_SMALL_INT) <= 0 ? ({ \ |
