diff --git a/core/math/big/basic.odin b/core/math/big/basic.odin index 5470bf917..69520a76c 100644 --- a/core/math/big/basic.odin +++ b/core/math/big/basic.odin @@ -1672,7 +1672,7 @@ _int_gcd_lcm :: proc(res_gcd, res_lcm, a, b: ^Int) -> (err: Error) { } -when size_of(rawptr) == 8 { +when MATH_BIG_FORCE_64_BIT || (!MATH_BIG_FORCE_32_BIT && size_of(rawptr) == 8) { _factorial_table := [35]_WORD{ /* f(00): */ 1, /* f(01): */ 1, diff --git a/core/math/big/common.odin b/core/math/big/common.odin index 7943c0e4b..1b76c9520 100644 --- a/core/math/big/common.odin +++ b/core/math/big/common.odin @@ -19,6 +19,12 @@ import "core:intrinsics" /* Tunables */ + +MATH_BIG_FORCE_64_BIT :: false; +MATH_BIG_FORCE_32_BIT :: false; +when (MATH_BIG_FORCE_32_BIT && MATH_BIG_FORCE_64_BIT) { #panic("Cannot force 32-bit and 64-bit big backend simultaneously."); }; + + _LOW_MEMORY :: #config(BIGINT_SMALL_MEMORY, false); when _LOW_MEMORY { _DEFAULT_DIGIT_COUNT :: 8; @@ -140,7 +146,7 @@ _MIN_DIGIT_COUNT :: max(3, ((size_of(u128) + _DIGIT_BITS) - 1) / _DIGIT_BITS); _MAX_BIT_COUNT :: (max(int) - 2); _MAX_DIGIT_COUNT :: _MAX_BIT_COUNT / _DIGIT_BITS; -when size_of(rawptr) == 8 { +when MATH_BIG_FORCE_64_BIT || (!MATH_BIG_FORCE_32_BIT && size_of(rawptr) == 8) { /* We can use u128 as an intermediary. */ diff --git a/core/math/big/helpers.odin b/core/math/big/helpers.odin index d4b5d0220..a326b960b 100644 --- a/core/math/big/helpers.odin +++ b/core/math/big/helpers.odin @@ -549,7 +549,7 @@ int_random_digit :: proc(r: ^rnd.Rand = nil) -> (res: DIGIT) { when _DIGIT_BITS == 60 { // DIGIT = u64 return DIGIT(rnd.uint64(r)) & _MASK; } else when _DIGIT_BITS == 28 { // DIGIT = u32 - return DIGIT(rand.uint32(r)) & _MASK; + return DIGIT(rnd.uint32(r)) & _MASK; } else { panic("Unsupported DIGIT size."); }