bigint: itoa works for numbers <= 120 bits.

This commit is contained in:
Jeroen van Rijn
2021-08-11 20:59:50 +02:00
parent e3d8ac559d
commit 341e8a3c99
3 changed files with 60 additions and 19 deletions
+1 -1
View File
@@ -88,6 +88,7 @@ set_integer :: proc(a: ^Int, n: $T, minimize := false, loc := #caller_location)
a.used = 0;
a.sign = .Zero_or_Positive if n >= 0 else .Negative;
n = abs(n);
for n != 0 {
a.digit[a.used] = DIGIT(n) & _MASK;
a.used += 1;
@@ -96,7 +97,6 @@ set_integer :: proc(a: ^Int, n: $T, minimize := false, loc := #caller_location)
if minimize {
shrink(a);
}
_zero_unused(a);
}