SIL.FieldWorks.SharpViews.LayoutTransform.MulDivNotToZero C# (CSharp) Method

MulDivNotToZero() static private method

Multiply the first two arguments and divide by the third. Assume the result will not overflow, but the intermediate product may be larger than an int. Round to the closest integer result, except that the result must not be zero unless the first argument is zero.
static private MulDivNotToZero ( int mp, int dpi, int div ) : int
mp int
dpi int
div int
return int
		internal static int MulDivNotToZero(int mp, int dpi, int div)
		{
			if (mp == 0)
				return 0; // this case is VERY common, handle efficiently.
			int result = MulDiv(mp, dpi, div);
			if (result != 0 )
				return result;
			return mp > 0 ? 1 : -1;
		}
	}