From b647f241213cfe209034937804a4de85ce991cbd Mon Sep 17 00:00:00 2001 From: Robbert van der Helm <mail@robbertvanderhelm.nl> Date: Tue, 10 Jan 2023 01:43:17 +0100 Subject: [PATCH] Fix rounding error in v2s_f32_hz_then_khz_with_note_name --- src/formatters.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formatters.rs b/src/formatters.rs index dab0eb8d..00a50796 100644 --- a/src/formatters.rs +++ b/src/formatters.rs @@ -146,7 +146,7 @@ pub fn v2s_f32_hz_then_khz_with_note_name( // This is the inverse of the formula in `f32_midi_note_to_freq` let fractional_note = util::freq_to_midi_note(value); let note = fractional_note.round(); - let cents = ((fractional_note - note) * 100.0) as i32; + let cents = ((fractional_note - note) * 100.0).round() as i32; let note_name = util::NOTES[(note as i32).rem_euclid(12) as usize]; let octave = (note as i32 / 12) - 1;