Fix edge case in uint->string conversion.
This commit is contained in:
parent
b2b72a08db
commit
c2b6c27d65
2 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue