From 47b3b7be256949ab1555d8e02a098a0e47c3c53a Mon Sep 17 00:00:00 2001 From: rowan Date: Mon, 23 Dec 2024 03:15:24 -0600 Subject: [PATCH] fix time count --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index def4c01..49dfcb5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use std::{ }; fn modf(value: f64) -> (f64, f64) { - (value.trunc(), value.fract().trunc()) + (value.trunc(), value.fract()) } fn count_words(input: &mut impl BufRead) -> io::Result { @@ -116,7 +116,8 @@ fn main() { count_words(&mut buf).expect("could not read from stdin") }; let time = count as f64 / cli.speed as f64; - let (mins, secs) = modf(time); + let (mins, fract) = modf(time); + let secs = (fract * 0.60f64 * 100f64).ceil(); println!("{count} words {mins}m{secs}s"); }