From d5bc7810e905f312e4b67bcace6ff5ce84d831e4 Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Tue, 17 Dec 2019 02:11:40 -0500 Subject: [PATCH] Switch back to round --- src/canvas.rs | 4 ++-- src/data_conversion.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/canvas.rs b/src/canvas.rs index baffb2d2..e5275a00 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -193,7 +193,7 @@ pub fn draw_data(terminal: &mut Terminal, app_state: &mu .labels(&["0%", "100%"]); let mem_name = "RAM:".to_string() - + &format!("{:3}%", (canvas_data.mem_data.last().unwrap_or(&(0_f64, 0_f64)).1.floor() as u64)) + + &format!("{:3}%", (canvas_data.mem_data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)) + &format!( " {:.1}GB/{:.1}GB", canvas_data.mem_values.first().unwrap_or(&(0, 0)).0 as f64 / 1024.0, @@ -211,7 +211,7 @@ pub fn draw_data(terminal: &mut Terminal, app_state: &mu if let Some(last_canvas_result) = (&canvas_data.swap_data).last() { if last_canvas_result.1 >= 0.0 { swap_name = "SWP:".to_string() - + &format!("{:3}%", (canvas_data.swap_data.last().unwrap_or(&(0_f64, 0_f64)).1.floor() as u64)) + + &format!("{:3}%", (canvas_data.swap_data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)) + &format!( " {:.1}GB/{:.1}GB", canvas_data.mem_values[1].0 as f64 / 1024.0, diff --git a/src/data_conversion.rs b/src/data_conversion.rs index b94af4c4..7fd63b39 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -211,7 +211,7 @@ fn convert_mem_data(mem_data: &[data_collection::mem::MemData]) -> Vec<(f64, f64 if data.mem_total_in_mb == 0 { -1000.0 } else { - data.mem_used_in_mb as f64 / data.mem_total_in_mb as f64 * 100_f64 + (data.mem_used_in_mb as f64 * 100_f64) / data.mem_total_in_mb as f64 }, );