aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-08-25 13:54:27 -0700
committerGraydon Hoare <[email protected]>2010-08-25 13:54:27 -0700
commitc2b6c27d65f09647d95bef39e2feefd767d045c1 (patch)
tree2f396100d75c3ce0e88dba8e9d0cb3597e15552a
parentJanitorial work on obj box / body / field terminology, following froystig's b... (diff)
downloadrust-c2b6c27d65f09647d95bef39e2feefd767d045c1.tar.xz
rust-c2b6c27d65f09647d95bef39e2feefd767d045c1.zip
Fix edge case in uint->string conversion.
-rw-r--r--src/lib/_uint.rs2
-rw-r--r--src/test/run-pass/lib-int.rs1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/_uint.rs b/src/lib/_uint.rs
index 897f0da6..f3a6f935 100644
--- a/src/lib/_uint.rs
+++ b/src/lib/_uint.rs
@@ -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;
}
}
diff --git a/src/test/run-pass/lib-int.rs b/src/test/run-pass/lib-int.rs
index ecca40b9..153c3683 100644
--- a/src/test/run-pass/lib-int.rs
+++ b/src/test/run-pass/lib-int.rs
@@ -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() {