aboutsummaryrefslogtreecommitdiff
path: root/src/format/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/mod.rs')
-rw-r--r--src/format/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/format/mod.rs b/src/format/mod.rs
index 4ac5612..baae301 100644
--- a/src/format/mod.rs
+++ b/src/format/mod.rs
@@ -35,7 +35,7 @@ fn radix_fmt(number: f64, obase: usize) -> Result<String, CalcError> {
35 let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect(); 35 let table: Vec<char> = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars().collect();
36 36
37 // format integral part of float 37 // format integral part of float
38 let mut integral = number.trunc() as i64; 38 let mut integral = number.abs().trunc() as i64;
39 let mut obase_int = String::new(); 39 let mut obase_int = String::new();
40 while integral >= obase as i64 { 40 while integral >= obase as i64 {
41 obase_int.push(table[(integral % obase as i64) as usize]); 41 obase_int.push(table[(integral % obase as i64) as usize]);
@@ -55,7 +55,7 @@ fn radix_fmt(number: f64, obase: usize) -> Result<String, CalcError> {
55 fract *= obase as f64; 55 fract *= obase as f64;
56 obase_fract.push(table[fract.trunc() as usize]); 56 obase_fract.push(table[fract.trunc() as usize]);
57 i += 1; 57 i += 1;
58 if fract.fract() == 0. || i > 10 { 58 if fract.fract() == 0. || i >= CONFIGURATION.fix {
59 break; 59 break;
60 } 60 }
61 fract = fract.fract(); 61 fract = fract.fract();