Skip to content

Commit 56f0979

Browse files
committed
Merge pull request #2164 from grahame/floatinfstr
write out "inf"/"-inf" in float::to_str_common
2 parents 599cbf7 + 2bee613 commit 56f0979

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libcore/float.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Converts a float to a string
4242
"]
4343
fn to_str_common(num: float, digits: uint, exact: bool) -> str {
4444
if is_NaN(num) { ret "NaN"; }
45+
if num == infinity { ret "inf"; }
46+
if num == neg_infinity { ret "-inf"; }
4547
let mut (num, accum) = if num < 0.0 { (-num, "-") } else { (num, "") };
4648
let trunc = num as uint;
4749
let mut frac = num - (trunc as float);

0 commit comments

Comments
 (0)