diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-11-24 20:22:36 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-11-24 20:22:36 -0500 |
| commit | bbf7a60dcd524c2d86ac7efe7bc97d4a627b6d15 (patch) | |
| tree | 837ef8f4df015ed82c6df2fff012cd3845698965 /src | |
| parent | 04ea51a81720be79170f185879a465e7020ed42b (diff) | |
Fix `from_num` incomplete renaming
Diffstat (limited to 'src')
| -rw-r--r-- | src/environment.c | 12 | ||||
| -rw-r--r-- | src/stdlib/bigint.h | 4 | ||||
| -rw-r--r-- | src/stdlib/intX.h | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/environment.c b/src/environment.c index d8c82513..6075ce49 100644 --- a/src/environment.c +++ b/src/environment.c @@ -459,7 +459,7 @@ env_t *global_env(bool source_mapping) { {"Int$from_int16", "func(i:Int16 -> Int)"}, // {"Int$from_int32", "func(i:Int32 -> Int)"}, // {"Int$from_int64", "func(i:Int64 -> Int)"}, // - {"Int$from_num", "func(n:Num, truncate=no -> Int)"}, // + {"Int$from_num64", "func(n:Num, truncate=no -> Int)"}, // {"Int$from_num32", "func(n:Num32, truncate=no -> Int)"}); ADD_CONSTRUCTORS("Int64", // {"Int64$from_bool", "func(b:Bool -> Int64)"}, // @@ -468,7 +468,7 @@ env_t *global_env(bool source_mapping) { {"Int64$from_int16", "func(i:Int16 -> Int64)"}, // {"Int64$from_int32", "func(i:Int32 -> Int64)"}, // {"Int64$from_int", "func(i:Int, truncate=no -> Int64)"}, // - {"Int64$from_num", "func(n:Num, truncate=no -> Int64)"}, // + {"Int64$from_num64", "func(n:Num, truncate=no -> Int64)"}, // {"Int64$from_num32", "func(n:Num32, truncate=no -> Int64)"}); ADD_CONSTRUCTORS("Int32", // {"Int32$from_bool", "func(b:Bool -> Int32)"}, // @@ -477,7 +477,7 @@ env_t *global_env(bool source_mapping) { {"Int32$from_int16", "func(i:Int16 -> Int32)"}, // {"Int32$from_int64", "func(i:Int64, truncate=no -> Int32)"}, // {"Int32$from_int", "func(i:Int, truncate=no -> Int32)"}, // - {"Int32$from_num", "func(n:Num, truncate=no -> Int32)"}, // + {"Int32$from_num64", "func(n:Num, truncate=no -> Int32)"}, // {"Int32$from_num32", "func(n:Num32, truncate=no -> Int32)"}); ADD_CONSTRUCTORS("Int16", // {"Int16$from_bool", "func(b:Bool -> Int16)"}, // @@ -486,7 +486,7 @@ env_t *global_env(bool source_mapping) { {"Int16$from_int32", "func(i:Int32, truncate=no -> Int16)"}, // {"Int16$from_int64", "func(i:Int64, truncate=no -> Int16)"}, // {"Int16$from_int", "func(i:Int, truncate=no -> Int16)"}, // - {"Int16$from_num", "func(n:Num, truncate=no -> Int16)"}, // + {"Int16$from_num64", "func(n:Num, truncate=no -> Int16)"}, // {"Int16$from_num32", "func(n:Num32, truncate=no -> Int16)"}); ADD_CONSTRUCTORS("Int8", // {"Int8$from_bool", "func(b:Bool -> Int8)"}, // @@ -495,7 +495,7 @@ env_t *global_env(bool source_mapping) { {"Int8$from_int32", "func(i:Int32, truncate=no -> Int8)"}, // {"Int8$from_int64", "func(i:Int64, truncate=no -> Int8)"}, // {"Int8$from_int", "func(i:Int, truncate=no -> Int8)"}, // - {"Int8$from_num", "func(n:Num, truncate=no -> Int8)"}, // + {"Int8$from_num64", "func(n:Num, truncate=no -> Int8)"}, // {"Int8$from_num32", "func(n:Num32, truncate=no -> Int8)"}); ADD_CONSTRUCTORS("Num", // {"Num$from_bool", "func(b:Bool -> Num)"}, // @@ -514,7 +514,7 @@ env_t *global_env(bool source_mapping) { {"Num32$from_int32", "func(i:Int32, truncate=no -> Num32)"}, // {"Num32$from_int64", "func(i:Int64, truncate=no -> Num32)"}, // {"Num32$from_int", "func(i:Int, truncate=no -> Num32)"}, // - {"Num32$from_num", "func(n:Num -> Num32)"}); + {"Num32$from_num64", "func(n:Num -> Num32)"}); ADD_CONSTRUCTORS("Path", // {"Path$escape_text", "func(text:Text -> Path)"}, // {"Path$escape_path", "func(path:Path -> Path)"}, // diff --git a/src/stdlib/bigint.h b/src/stdlib/bigint.h index 614e1501..a00bdf2f 100644 --- a/src/stdlib/bigint.h +++ b/src/stdlib/bigint.h @@ -189,13 +189,13 @@ MACROLIKE PUREFUNC bool Int$is_negative(Int_t x) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif -MACROLIKE PUREFUNC Int_t Int$from_num(double n, bool truncate) { +MACROLIKE PUREFUNC Int_t Int$from_num64(double n, bool truncate) { mpz_t result; mpz_init_set_d(result, n); if (!truncate && unlikely(mpz_get_d(result) != n)) fail("Could not convert to an integer without truncation: ", n); return Int$from_mpz(result); } -MACROLIKE PUREFUNC Int_t Int$from_num32(float n, bool truncate) { return Int$from_num((double)n, truncate); } +MACROLIKE PUREFUNC Int_t Int$from_num32(float n, bool truncate) { return Int$from_num64((double)n, truncate); } MACROLIKE Int_t Int$from_int64(int64_t i) { if likely (i >= SMALLEST_SMALL_INT && i <= BIGGEST_SMALL_INT) return (Int_t){.small = (i << 2L) | 1L}; mpz_t result; diff --git a/src/stdlib/intX.h b/src/stdlib/intX.h index 765543fd..0f4632c2 100644 --- a/src/stdlib/intX.h +++ b/src/stdlib/intX.h @@ -88,7 +88,7 @@ MACROLIKE PUREFUNC INTX_T NAMESPACED(unsigned_right_shifted)(INTX_T x, INTX_T y) void NAMESPACED(serialize)(const void *obj, FILE *out, Table_t *, const TypeInfo_t *); void NAMESPACED(deserialize)(FILE *in, void *outval, List_t *, const TypeInfo_t *); -MACROLIKE PUREFUNC INTX_T NAMESPACED(from_num)(Num_t n, bool truncate) { +MACROLIKE PUREFUNC INTX_T NAMESPACED(from_num64)(Num_t n, bool truncate) { INTX_T i = (INTX_T)n; if (!truncate && unlikely((Num_t)i != n)) fail("Could not convert Num to an " NAME_STR " without truncation: ", n); return i; |
