Microsoft DirectX 8.1 (C++)

Int64x32Div32

The Int64x32Div32 function implements the formula ((a*b)+rnd)/c where a is a 64-bit value and b, c, and rnd are 32-bit values.

Time stamps and seek times are 64-bit values, so this function is useful for performing conversions on 32-bit systems. For example, in MPEG-1 the system clock reference is 90-kHz, or 90,000 ticks per second. The formula to convert this to reference time (100-nanosecond units) is

(timestamp * 1000) / 9

which can be calculated as Int64x32Div32(timestamp, 1000, 9, 0). Use the rnd parameter as a rounding factor.

Syntax

LONGLONG WINAPI Int64x32Div32(
  LONGLONG a,
  LONG b,
  LONG c,
  LONG rnd
);

Return Value

Returns either the (a * b + rnd)/c calculation or one of the following values.

0x7FFFFFFFFFFFFFFF Overflow occurred because the result is too large (positive).
0x8000000000000000 Overflow occurred because the result is too large (negative).

Remarks

Rounding on the division is toward zero. Division by zero is counted as an overflow condition.

See Also