From 4e8564b5965a41d0e57752cb8b51e6c13d9a53e2 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 19 Oct 2022 11:11:24 +0900 Subject: [PATCH] Round values when determining netgraph output --- Changelog.md | 3 +++ src/proc.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 241c1b0..80803e9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,9 @@ Minor refactoring of how the netgraph string is handled. Refactoring of handling of Option types wrapping primitive values. +Round values when determining netgraph results instead of truncating to an +integer. + ## 0.1.5 Implemented `--netdev_width=` which sets the minimum width of the netdev diff --git a/src/proc.rs b/src/proc.rs index 4dd5c14..69bb6e3 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -143,7 +143,7 @@ impl NetInfo { let graph_value: u8 = if diff_max > graph_max { 8 } else { - (diff_max / graph_max * 8.0f64) as u8 + (diff_max / graph_max * 8.0f64).round() as u8 }; self.graph.remove(0);