Skip to content

Instantly share code, notes, and snippets.

@jwasinger
Created October 2, 2020 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwasinger/2b7950e5b29ac42c44228a286bb8c069 to your computer and use it in GitHub Desktop.
Save jwasinger/2b7950e5b29ac42c44228a286bb8c069 to your computer and use it in GitHub Desktop.
C++ vs Python (uint128)
#include <stdint.h>
#include <iostream>
int main(int argc, char **argv) {
uint64_t x = 12823323627408599439;
uint64_t y = 5504717096808338412;
__uint128_t res = (__uint128_t)x * y;
std::cout << x << " * " << y << " = " << (uint64_t)res << ", " << (uint64_t)(res >> 64) << std::endl;
}
x = 12823323627408599439
y = 5504717096808338412
print(x, " * ", y, " = ", x * y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment