]> git.seodisparate.com - mpd_info_screen/commitdiff
Round percentage value 0.4.12
authorStephen Seo <seo.disparate@gmail.com>
Mon, 24 Jun 2024 05:11:10 +0000 (14:11 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 24 Jun 2024 05:11:10 +0000 (14:11 +0900)
src/display.rs

index 0c57b46b4a659c65dbc4c717154ab6e613f022df..09db0434c475008f16b1a7cb773e36a897ee17b2 100644 (file)
@@ -55,7 +55,7 @@ fn seconds_to_time(seconds: f64) -> String {
 }
 
 fn time_to_percentage(total: f64, current: f64) -> String {
-    let result = (100.0f64 * current / total).to_string();
+    let result = (100.0f64 * current / total).round().to_string();
     match result.split_once('.') {
         Some((a, _)) => a.to_string() + "%",
         None => result + "%",