logic fix

main
Elfein Landers 2022-03-14 04:17:39 -07:00
parent ab04dcea5d
commit 29856381e5
1 changed files with 7 additions and 6 deletions

View File

@ -20,9 +20,15 @@ fn hex_float(h: f64) -> String {
h *= 16.0;
e += 1;
}
let mut h = h as usize;
let mut output = String::new();
if e == 0 {
output.push('0');
output.push('.');
}
let mut num_divides = 0;
while h > 0 {
output.push(match h % 16 {
@ -51,11 +57,6 @@ fn hex_float(h: f64) -> String {
}
}
if e == 0 {
output.push('.');
output.push('0');
}
if neg {
output.push('-');
}
@ -65,7 +66,7 @@ fn hex_float(h: f64) -> String {
#[test]
fn test_hex_float() {
assert_eq!["1.8", hex_float(1.5)];
assert_eq!["1.8", hex_float(f64::MAX)];
}
fn separate_units(n: usize, how_base: HowNumberBase) -> String {