Intrebute
6/23/2017 - 9:58 PM

Actual modulus calculated using the finicky % operator. Uncomment the Expects and Ensures lines if using the GSL: https://github.com/Microso

Actual modulus calculated using the finicky % operator. Uncomment the Expects and Ensures lines if using the GSL: https://github.com/Microsoft/GSL

int mod(int n, int max)
{
	//Expects(max > 0);
	int res = 0;
	if (n >= 0)
	{
		res = n % max;
	}
	else
	{
		res = (max - (-n % max)) % max;
	}
	//Ensures(0 <= res && res < max);
	return res;
}