Expand Minimize

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(
  _In_  int nNumber,
  _In_  int nNumerator,
  _In_  int nDenominator
);

Parameters

nNumber [in]

The multiplicand.

nNumerator [in]

The multiplier.

nDenominator [in]

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 | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

Large Integers
Int32x32To64
UInt32x32To64

 

 

Community Additions

ADD
Show:
© 2014 Microsoft