remainder function
Returns the remainder of the modulo operation input
% source
, and adjust it for
negative values.
Implementation
int remainder(int input, int? source) {
if (source == 0) return 0;
final int result = input % source!;
return result < 0 ? source + result : result;
}