Skip to content

Commit 621c98a

Browse files
committed
fix rounding
1 parent c502202 commit 621c98a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/playback/speed/CustomPlaybackSpeedPatch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ private static int speedToProgressValue(float speed) {
617617
* @return The rounded speed, constrained to the specified bounds.
618618
*/
619619
private static float roundSpeedToNearestIncrement(float speed) {
620-
// Round to nearest 0.05 speed.
621-
final float roundedSpeed = Math.round(speed / 0.05f) * 0.05f;
622-
return Utils.clamp(roundedSpeed, 0.05f, PLAYBACK_SPEED_MAXIMUM);
620+
// Round to nearest 0.05 speed. Must use double precision otherwise rounding error can occur.
621+
final double roundedSpeed = Math.round(speed / 0.05) * 0.05;
622+
return Utils.clamp((float) roundedSpeed, 0.05f, PLAYBACK_SPEED_MAXIMUM);
623623
}
624624

625625
/**

0 commit comments

Comments
 (0)