mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -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 {
|
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
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user