]> git.lizzy.rs Git - rust.git/commitdiff
write out "inf"/"-inf" in float::to_str_common
authorGrahame Bowland <grahame@angrygoats.net>
Sun, 8 Apr 2012 17:33:36 +0000 (01:33 +0800)
committerGrahame Bowland <grahame@angrygoats.net>
Sun, 8 Apr 2012 17:33:36 +0000 (01:33 +0800)
src/libcore/float.rs

index 9699032dd77083b3ad589eaafa4fdb7617410228..fa7a493d8a1c280bbdc478da71583946c75ef99f 100644 (file)
@@ -42,6 +42,8 @@
 "]
 fn to_str_common(num: float, digits: uint, exact: bool) -> str {
     if is_NaN(num) { ret "NaN"; }
+    if num == infinity { ret "inf"; }
+    if num == neg_infinity { ret "-inf"; }
     let mut (num, accum) = if num < 0.0 { (-num, "-") } else { (num, "") };
     let trunc = num as uint;
     let mut frac = num - (trunc as float);