MulDiv function

Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value. The final result is rounded to the nearest integer.

Syntax

int MulDiv(
  int nNumber,
  int nNumerator,
  int nDenominator
);

Parameters

nNumber

The multiplicand.

nNumerator

The multiplier.

nDenominator

The number by which the result of the multiplication operation is to be divided.

Return Value

If the function succeeds, the return value is the result of the multiplication and division, rounded to the nearest integer. If the result is a positive half integer (ends in .5), it is rounded up. If the result is a negative half integer, it is rounded down.

If either an overflow occurred or nDenominator was 0, the return value is -1.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

Int32x32To64

Large Integers

UInt32x32To64