mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-25 21:28:13 +00:00
Use normal i64 arithmetic instead of big-ints for hot path
This commit is contained in:
@@ -57,6 +57,8 @@ gb_internal void big_int_dealloc(BigInt *dst) {
|
||||
mp_clear(dst);
|
||||
}
|
||||
|
||||
gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x);
|
||||
|
||||
gb_internal BigInt big_int_make(BigInt const *b, bool abs=false);
|
||||
gb_internal BigInt big_int_make_abs(BigInt const *b);
|
||||
gb_internal BigInt big_int_make_u64(u64 x);
|
||||
@@ -293,6 +295,11 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success
|
||||
|
||||
|
||||
|
||||
gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x) {
|
||||
int bits_used = (x->used-1) * MP_DIGIT_BIT;
|
||||
return bits_used <= 64;
|
||||
}
|
||||
|
||||
gb_internal u64 big_int_to_u64(BigInt const *x) {
|
||||
GB_ASSERT(x->sign == 0);
|
||||
return mp_get_u64(x);
|
||||
|
||||
Reference in New Issue
Block a user