mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-19 21:44:38 -04:00
fix(tracker): the mod function could return negative values with mod(-1,1)
Never copy-paste code from the internets
This commit is contained in:
@ -94,12 +94,8 @@ func (r *SongRect) Contains(p SongPoint) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mod(a, b int) int {
|
func mod(a, b int) int {
|
||||||
m := a % b
|
if a < 0 {
|
||||||
if a < 0 && b < 0 {
|
return b - 1 - mod(-a-1, b)
|
||||||
m -= b
|
|
||||||
}
|
}
|
||||||
if a < 0 && b > 0 {
|
return a % b
|
||||||
m += b
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user