Always consider floats as approx. when displayed

This commit is contained in:
Tiffany Bennett 2016-09-26 00:05:25 -04:00
parent 1b3109a263
commit b5cec68217

View file

@ -628,15 +628,24 @@ impl Number {
} }
pub fn numeric_value(&self, base: u8) -> (Option<String>, Option<String>) { pub fn numeric_value(&self, base: u8) -> (Option<String>, Option<String>) {
let (num, den) = self.0.to_rational(); match self.0 {
match to_string(&self.0, base) { Num::Mpq(ref mpq) => {
(true, v) => (Some(v), None), let num = mpq.get_num();
(false, v) => if {den > Mpz::from(1_000_000) || let den = mpq.get_den();
num > Mpz::from(1_000_000_000u64)} {
(None, Some(v)) match to_string(&self.0, base) {
} else { (true, v) => (Some(v), None),
(Some(format!("{}/{}", num, den)), Some(v)) (false, v) => if {den > Mpz::from(1_000_000) ||
} num > Mpz::from(1_000_000_000u64)} {
(None, Some(v))
} else {
(Some(format!("{}/{}", num, den)), Some(v))
}
}
},
Num::Float(_f) => {
(None, Some(to_string(&self.0, base).1))
},
} }
} }