Pixel-Composer/scripts/safe_operation/safe_operation.gml
2023-11-08 14:38:04 +07:00

16 lines
No EOL
231 B
Text

enum MOD_NEG {
_default,
wrap
}
function safe_mod(numb, modd, _neg = MOD_NEG._default) {
INLINE
var _md = modd == 0? 0 : numb % modd;
if(_md < 0)
switch(_neg) {
case MOD_NEG.wrap : _md += modd; break;
}
return _md;
}