A detailed walkthrough of implementing a fixed-width 128-bit unsigned integer type in C++ using two 64-bit limbs. The implementation leverages compiler intrinsics (_addcarry_u64, _subborrow_u64, _mulx_u64) that map directly to x64 instructions (adc, sbb, mulx) to achieve performance matching the builtin __uint128_t. Covers
•11m read time• From solidean.com
Table of contents
ScopeWhy fixed-width big integersRepresentationAddition, with carrySubtraction: same story, invertedMultiplication: regrouping our u64 digitsEqualityComparison: borrow beats branchingA small use sitePlatform notesOutlookAddendum 2026-01-24Sort: