cgul_multiply64_cxx Namespace Reference

C++ bindings for cgul_multiply64 More...

Functions

void multiply64 (unsigned int x, unsigned int y, unsigned int *high, unsigned int *low)
 

Detailed Description

This namespace provides the C++ bindings for cgul_multiply64. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_multiply64 into C++-style function calls and exception handling.

Function Documentation

§ multiply64()

void cgul_multiply64_cxx::multiply64 ( unsigned int  x,
unsigned int  y,
unsigned int *  high,
unsigned int *  low 
)
inline

This function multiplies two 32-bit unsigned integers x and y to produce a 64-bit unsigned product using only 32-bit arithmetic. The high 32-bits of the 64-bit product will be stored in *high if high is not NULL, and the low 32-bits of the 64-bit product will be stored in *low if low is not NULL.

The following printf() format specification can be used to convert *high and *low into a proper hexadecimal string because it accounts for the significance of the leading zeros in *low:

    printf("%#0x%08x", *high, *low);

This function takes about 2.5 times as long to run as native 64-bit multiplication. Thus, it should only be used if your compiler does not support a 64-bit type. To conditionally use this code, include the "cgul_int.h" header and test if CGUL_UINT64 is not defined.

Parameters
[in]xfirst 32-bit multiplicand
[in]ysecond 32-bit multiplicand
[out]highhigh 32-bits of the product of x and y
[out]lowlow 32-bits of the product of x and y

References cgul_multiply64().