From 4ce6abe1e82035a4bb9de8d13fb693ad9137a583 Mon Sep 17 00:00:00 2001 From: vsariola <5684185+vsariola@users.noreply.github.com> Date: Sat, 10 Apr 2021 19:17:38 +0300 Subject: [PATCH] fix(tracker): the mod function could return negative values with mod(-1,1) Never copy-paste code from the internets --- tracker/songpoint.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tracker/songpoint.go b/tracker/songpoint.go index d0e3232..9bfaaa7 100644 --- a/tracker/songpoint.go +++ b/tracker/songpoint.go @@ -94,12 +94,8 @@ func (r *SongRect) Contains(p SongPoint) bool { } func mod(a, b int) int { - m := a % b - if a < 0 && b < 0 { - m -= b + if a < 0 { + return b - 1 - mod(-a-1, b) } - if a < 0 && b > 0 { - m += b - } - return m + return a % b }