Last active
April 12, 2022 01:23
-
-
Save dmwit/c0abc5995739bc750b8e2d85c7166b4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "32x32to64mul.h" | |
uint64_t mul64(uint32_t, uint32_t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline uint64_t mul64(uint32_t x, uint32_t y) { | |
uint32_t xlo = x&0xffff, xhi = x>>16, ylo = y&0xffff, yhi = y>>16; | |
return ((uint64_t)(xhi*yhi) << 32) | |
+ ((uint64_t)(xhi*ylo) << 16) | |
+ ((uint64_t)(xlo*yhi) << 16) | |
+ ((uint64_t)(xlo*ylo) << 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment