From c6b03d82daa4d6b4856c4b33244f5261b0bbdaeb Mon Sep 17 00:00:00 2001 From: Milan Markovic Date: Tue, 2 Jul 2019 21:55:22 +0000 Subject: Fixed infinity and nan cases in pprint --- src/format/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/format') diff --git a/src/format/mod.rs b/src/format/mod.rs index ee77042..3e3ade2 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -36,12 +36,14 @@ fn radix_fmt(number: f64, obase: usize) -> Result { return Err(CalcError::Math(Math::UnknownBase)); } - if number.is_infinite(){ - return Ok("Inf".to_string()); + match (number.is_infinite(), number.is_sign_positive()) { + (true, true) => return Ok("inf".to_string()), + (true, false) => return Ok("-inf".to_string()), + _ => () } if number.is_nan(){ - return Ok("Nan".to_string()); + return Ok("nan".to_string()); } let table: Vec = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); -- cgit v1.2.3