3 ms·
How do they do single digit multiplication? Most(?) 64-bit CPUs have a 64bit × 64bit → 128bit multiplication instruction; but AFAIK the C++ language doesn't ha
by jwilk 9y ago
How do they do single digit multiplication?
Most(?) 64-bit CPUs have a 64bit × 64bit → 128bit multiplication instruction; but AFAIK the C++ language doesn't have anything like this.
- stephencanon 9y agoBoth clang and gcc expose it via the __[u]int128_t extension.
- mmozeiko 9y agoMSVC also can do this with _mul128 intrinsic.
- jwilk 9y agoThat's how they did it indeed. They have also fallback code for when this the double-width integer type is not available. https://github.com/v8/v8/blob/6.8.137/src/objects/bigint.cc#L2289 https://github.com/v8/v8/blob/6.8.137/src/objects/bigint.cc#...