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"); }