bbfa3023a491e15cd1f8d83589ab2ae8b274f7d6
7 /***********************************************************************
10 * Result of multiplication and division
11 * -1: Overflow occurred or Divisor was 0
12 * FIXME! move to correct file
25 /* Find out if this will be a negative result */
26 Negative
= nNumber
^ nNumerator
^ nDenominator
;
28 /* Turn all the parameters into absolute values */
29 if (nNumber
< 0) nNumber
*= -1;
30 if (nNumerator
< 0) nNumerator
*= -1;
31 if (nDenominator
< 0) nDenominator
*= -1;
33 /* Calculate the result */
34 Result
.QuadPart
= Int32x32To64(nNumber
, nNumerator
) + (nDenominator
/ 2);
36 /* Now check for overflow */
37 if (nDenominator
> Result
.HighPart
)
39 /* Divide the product to get the quotient and remainder */
40 Result
.LowPart
= RtlEnlargedUnsignedDivide(*(PULARGE_INTEGER
)&Result
,
44 /* Do the sign changes */
45 if ((LONG
)Result
.LowPart
>= 0)
47 return (Negative
>= 0) ? Result
.LowPart
: -(LONG
)Result
.LowPart
;