Fix edge case in uint->string conversion.

This commit is contained in:
Graydon Hoare 2010-08-25 13:54:27 -07:00
parent b2b72a08db
commit c2b6c27d65
2 changed files with 2 additions and 1 deletions

View file

@ -61,7 +61,7 @@ fn to_str(mutable uint n, uint radix) -> str
let uint r = 1u;
if (n > r) {
while ((r*radix) < n) {
while ((r*radix) <= n) {
r *= radix;
}
}

View file

@ -8,6 +8,7 @@ fn test_to_str() {
check (eq(_int.to_str(1, 10u), "1"));
check (eq(_int.to_str(-1, 10u), "-1"));
check (eq(_int.to_str(255, 16u), "ff"));
check (eq(_int.to_str(100, 10u), "100"));
}
fn main() {