big: itoa now works for arbitrary radixes.

This commit is contained in:
Jeroen van Rijn
2021-08-11 20:59:51 +02:00
parent c2255c6c19
commit 1ebaa9fb3b
4 changed files with 202 additions and 80 deletions
-8
View File
@@ -217,8 +217,6 @@ int_log_digit :: proc(a: DIGIT, base: DIGIT) -> (log: int, err: Error) {
_int_log :: proc(a: ^Int, base: DIGIT) -> (res: int, err: Error) {
bracket_low, bracket_high, bracket_mid, t, bi_base := &Int{}, &Int{}, &Int{}, &Int{}, &Int{};
cnt := 0;
ic, _ := cmp(a, base);
if ic == -1 || ic == 0 {
return 1 if ic == 0 else 0, .None;
@@ -256,12 +254,6 @@ _int_log :: proc(a: ^Int, base: DIGIT) -> (res: int, err: Error) {
destroy(bracket_low, bracket_high, bracket_mid, t, bi_base);
return -1, err;
}
cnt += 1;
if cnt == 7 {
destroy(bracket_low, bracket_high, bracket_mid, t, bi_base);
return -2, .Max_Iterations_Reached;
}
}
for (high - low) > 1 {