aboutsummaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorMilan Markovic <[email protected]>2019-07-02 22:55:22 +0100
committerMilan Markovic <[email protected]>2019-07-02 22:55:22 +0100
commitc6b03d82daa4d6b4856c4b33244f5261b0bbdaeb (patch)
treea4c6d4800491a8fd9c5f27d9e54118d83fbe13ab /src/format
parentec7ae4eb7a07e5f9330334247dd6ca1722582f02 (diff)
Fixed infinity and nan cases in pprint
Diffstat (limited to 'src/format')
-rw-r--r--src/format/mod.rs8
1 files changed, 5 insertions, 3 deletions
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<String, CalcError> {
36 return Err(CalcError::Math(Math::UnknownBase)); 36 return Err(CalcError::Math(Math::UnknownBase));
37 } 37 }
38 38
39 if number.is_infinite(){ 39 match (number.is_infinite(), number.is_sign_positive()) {
40 return Ok("Inf".to_string()); 40 (true, true) => return Ok("inf".to_string()),
41 (true, false) => return Ok("-inf".to_string()),
42 _ => ()
41 } 43 }
42 44
43 if number.is_nan(){ 45 if number.is_nan(){
44 return Ok("Nan".to_string()); 46 return Ok("nan".to_string());
45 } 47 }
46 48
47 let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); 49 let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect();