The search keyword must be a single word (no spaces).
Function ModuloReal
- Line
- 857
- Location
- blizzard.j
- Constant?
- no
- Type
- function
- Arguments
- real dividend, real divisor
- Returns
- real
| 857 | function ModuloReal takes real dividend, real divisor returns real |
| 858 | local real modulus = dividend - I2R(R2I(dividend / divisor)) * divisor |
| 859 | |
| 860 | // If the dividend was negative, the above modulus calculation will
|
| 861 | // be negative, but within (-divisor..0). We can add (divisor) to
|
| 862 | // shift this result into the desired range of (0..divisor).
|
| 863 | if (modulus < 0) then |
| 864 | set modulus = modulus + divisor |
| 865 | endif
|
| 866 | |
| 867 | return modulus
|
| 868 | endfunction
|