bigint: Working on itoa and logn.

This commit is contained in:
Jeroen van Rijn
2021-08-11 20:59:50 +02:00
parent 905d5459a9
commit dbcd8da733
6 changed files with 172 additions and 28 deletions
+23
View File
@@ -29,6 +29,29 @@ is_negative :: proc(a: ^Int) -> bool {
}
is_neg :: is_negative;
is_even :: proc(a: ^Int) -> bool {
if is_initialized(a) {
if is_zero(a) {
return true;
}
if a.used > 0 && a.digit[0] & 1 == 0 {
return true;
}
}
return false;
}
is_odd :: proc(a: ^Int) -> bool {
if is_initialized(a) {
return !is_even(a);
}
return false;
}
is_power_of_two :: proc(x: int) -> bool {
return ((x) != 0) && (((x) & ((x) - 1)) == 0);
}
/*
Compare two `Int`s, signed.
*/