From 2bee6132f9a3c2475808da90beba4b20fb12a6eb Mon Sep 17 00:00:00 2001 From: Grahame Bowland Date: Mon, 9 Apr 2012 01:33:36 +0800 Subject: [PATCH] write out "inf"/"-inf" in float::to_str_common --- src/libcore/float.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 9699032dd77..fa7a493d8a1 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -42,6 +42,8 @@ Converts a float to a string "] 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);