Skip to content

Commit efc6f4e

Browse files
fix(ui): exactly three significant digits within tooltips
Signed-off-by: Maika Namuo <httpworldview@gmail.com>
1 parent 233beec commit efc6f4e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎src/util/audio.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ pub fn sanitize_sample_rate(sample_rate: f32) -> f32 {
5050

5151
pub fn fmt_freq(frequency: f32) -> String {
5252
match frequency {
53-
f if f >= 10_000.0 => format!("{:.1}kHz", f / 1000.0),
54-
f if f >= 1_000.0 => format!("{:.2}kHz", f / 1000.0),
55-
f if f >= 100.0 => format!("{f:.1}Hz"),
56-
f => format!("{f:.2}Hz"),
53+
99_950.0.. => format!("{:.0}kHz", frequency / 1_000.0),
54+
9_995.0.. => format!("{:.1}kHz", frequency / 1_000.0),
55+
999.5.. => format!("{:.2}kHz", frequency / 1_000.0),
56+
99.95.. => format!("{frequency:.0}Hz"),
57+
9.995.. => format!("{frequency:.1}Hz"),
58+
_ => format!("{frequency:.2}Hz"),
5759
}
5860
}
5961

0 commit comments

Comments
 (0)