From ec7ae4eb7a07e5f9330334247dd6ca1722582f02 Mon Sep 17 00:00:00 2001 From: Milan Markovic Date: Tue, 2 Jul 2019 21:49:27 +0000 Subject: Added inf and nan --- src/format/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { return Err(CalcError::Math(Math::UnknownBase)); } + if number.is_infinite(){ + return Ok("Inf".to_string()); + } + + if number.is_nan(){ + return Ok("Nan".to_string()); + } + let table: Vec = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); // format integral part of float -- cgit v1.2.3