Why not just make 2 distinct mods which you can then call upon to get the output in whatever format you want?
Code: (Select All)
Print ModP(10, 3), 10 Mod 3, ModN(10, 3)
Print ModP(10, -3), 10 Mod -3, ModN(10, -3)
Print ModP(-10, 3), 10 Mod 3, ModN(-10, 3)
Print ModP(-10, -3), 10 Mod -3, ModN(-10, -3)
Print ModP(10, 3.14), 10 Mod 3.14, ModN(10, 3.14)
Print ModP(10, -3.14), 10 Mod -3.14, ModN(10, -3.14)
Print ModP(-10, 3.14), -10 Mod 3.14, ModN(-10, 3.14)
Print ModP(-10, -3.14), -10 Mod -3.14, ModN(-10, -3.14)
Function ModP## (num As _Float, div As _Float)
Dim tempValue As _Float
If div = 0 Then Error 5: Exit Function
tempValue = num - Int(num / div) * div
If tempValue < 0 Then tempValue = tempValue + Abs(div)
ModP = tempValue
End Function
Function ModN## (num As _Float, div As _Float)
Dim tempValue As _Float
If div = 0 Then Error 5: Exit Function
tempValue = num - Int(num / div) * div
If tempValue > 0 Then tempValue = tempValue - Abs(div)
ModN = tempValue
End Function