diff options
author | Milan Markovic <[email protected]> | 2019-07-02 22:49:27 +0100 |
---|---|---|
committer | Milan Markovic <[email protected]> | 2019-07-02 22:49:27 +0100 |
commit | ec7ae4eb7a07e5f9330334247dd6ca1722582f02 (patch) | |
tree | 3e8c5ede0f40d198be1e288237d317c9d5f6a868 /src | |
parent | a01e3bd9896adcf28a89fbbd09235747319b8113 (diff) |
Added inf and nan
Diffstat (limited to 'src')
-rw-r--r-- | src/format/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/format/mod.rs b/src/format/mod.rs index 2ba7ad9..ee77042 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs | |||
@@ -36,6 +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(){ | ||
40 | return Ok("Inf".to_string()); | ||
41 | } | ||
42 | |||
43 | if number.is_nan(){ | ||
44 | return Ok("Nan".to_string()); | ||
45 | } | ||
46 | |||
39 | let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); | 47 | let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); |
40 | 48 | ||
41 | // format integral part of float | 49 | // format integral part of float |