fix time count
This commit is contained in:
parent
3d032fee4b
commit
47b3b7be25
1 changed files with 3 additions and 2 deletions
|
@ -9,7 +9,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
fn modf(value: f64) -> (f64, f64) {
|
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> {
|
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")
|
count_words(&mut buf).expect("could not read from stdin")
|
||||||
};
|
};
|
||||||
let time = count as f64 / cli.speed as f64;
|
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");
|
println!("{count} words {mins}m{secs}s");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue