mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Simplify big_int_not for negative inputs
This commit is contained in:
@@ -415,6 +415,14 @@ void big_int_not(BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed) {
|
|||||||
big_int_from_u64(dst, 0);
|
big_int_from_u64(dst, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (big_int_is_neg(x)) {
|
||||||
|
// ~x == -x - 1
|
||||||
|
big_int_neg(dst, x);
|
||||||
|
mp_decr(dst);
|
||||||
|
mp_mod_2d(dst, bit_count, dst);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BigInt pow2b = {};
|
BigInt pow2b = {};
|
||||||
mp_2expt(&pow2b, bit_count);
|
mp_2expt(&pow2b, bit_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user