Skip to content

Commit

Permalink
Fix improper conversion of floats
Browse files Browse the repository at this point in the history
  • Loading branch information
C0D3-M4513R committed Jun 14, 2024
1 parent e54df3d commit 0842ea8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions counter/src/counter_or_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ impl Widget for &mut CounterTimer{
if neg {
sec = -sec;
}
let s = sec%SECONDS_IN_MINUTE as f64;
let min = sec/SECONDS_IN_MINUTE as f64;
let hr = min/MINUTES_IN_HOUR as f64;
let min = min %MINUTES_IN_HOUR as f64;
let s = sec.rem_euclid(SECONDS_IN_MINUTE as f64);
let min = sec.div_euclid(SECONDS_IN_MINUTE as f64);
let hr = min.div_euclid(MINUTES_IN_HOUR as f64);
let min = min.rem_euclid(MINUTES_IN_HOUR as f64);
format!("{0}{hr:02.0}:{min:02.0}:{s:02.0}", if neg {"-"} else {""})
}).custom_parser(|string|{
let neg = string.strip_prefix("-");
Expand Down

0 comments on commit 0842ea8

Please sign in to comment.