fix time count

This commit is contained in:
Rowan 2024-12-23 03:15:24 -06:00
parent 3d032fee4b
commit 47b3b7be25

View file

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