diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 02:51:10 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-13 02:51:10 -0400 |
| commit | 2c4f6536a34cb55a5dcaf73908b7ea056da802a9 (patch) | |
| tree | 27de91078ac6c0c286b8d769d4b6a4b79d1d7b28 /builtins/integers.c | |
| parent | f4011eb489d97bbf3170c81a985a09568bfc0dd7 (diff) | |
Fix Int->Num promotions
Diffstat (limited to 'builtins/integers.c')
| -rw-r--r-- | builtins/integers.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/builtins/integers.c b/builtins/integers.c index eaaae660..b50d61c2 100644 --- a/builtins/integers.c +++ b/builtins/integers.c @@ -36,6 +36,14 @@ public Int_t Int$from_num(double n) return Int$from_mpz(result); } +public double Int$as_num(Int_t i) +{ + if (__builtin_expect(i.small & 1, 1)) + return (double)(i.small >> 2); + + return mpz_get_d(*i.big); +} + public CORD Int$as_text(const Int_t *i, bool colorize, const TypeInfo *type) { (void)type; if (!i) return "Int"; |
