We recommend using Visual Studio 2017



The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at __umulh.

Microsoft Specific**

Return the high 64 bits of the product of two 64-bit unsigned integers.

unsigned __int64 __umulh(   
   unsigned __int64 a,   
   unsigned __int64 b   


[in] a
The first number to multiply.

[in] b
The second number to multiply.

The high 64 bits of the 128-bit result of the multiplication.


Header file <intrin.h>

These routines are only available as intrinsics.

// umulh.cpp  
// processor: X64  
#include <cstdio>  
#include <intrin.h>  
int main()  
    unsigned __int64 i = 0x10;  
    unsigned __int64 j = 0xFEDCBA9876543210;  
    unsigned __int64 k = i * j; // k has the low 64 bits  
                                // of the product.  
    unsigned __int64 result;  
    result = __umulh(i, j); // result has the high 64 bits  
                            // of the product.  
    printf_s("0x%I64x * 0x%I64x = 0x%I64x%I64x \n", i, j, result, k);  
    return 0;  

0x10 * 0xfedcba9876543210 = 0xfedcba98765432100   

Compiler Intrinsics