The search keyword must be a single word (no spaces).
Function ModuloInteger
- Line
- 840
- Location
- blizzard.j
- Constant?
- no
- Type
- function
- Arguments
- integer dividend, integer divisor
- Returns
- integer
| 840 | function ModuloInteger takes integer dividend, integer divisor returns integer |
| 841 | local integer modulus = dividend - (dividend / divisor) * divisor |
| 842 | |
| 843 | // If the dividend was negative, the above modulus calculation will
|
| 844 | // be negative, but within (-divisor..0). We can add (divisor) to
|
| 845 | // shift this result into the desired range of (0..divisor).
|
| 846 | if (modulus < 0) then |
| 847 | set modulus = modulus + divisor |
| 848 | endif
|
| 849 | |
| 850 | return modulus
|
| 851 | endfunction
|
Information about ModuloInteger
City17
4 years
You must be logged in with a standard account to contribute.