mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -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:
parent
d04895144b
commit
4ce6abe1e8
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user