> static inline Int128 int128_neg(Int128 a) > { > - a.lo = ~a.lo; > - a.hi = ~a.hi; > - return int128_add(a, int128_one()); > + uint64_t lo = -a.lo; > + return (Int128) { lo, ~a.hi + !lo }; > }
This leaves int128_one unused. (Also the temporary lo seems a bit pointless, since you could just as well write -a.lo and !a.lo.) > static inline bool int128_ge(Int128 a, Int128 b) > { > - return int128_nonneg(int128_sub(a, b)); > + return a.hi > b.hi || (a.hi == b.hi && a.lo >= b.lo); > } This is a bug fix. The old version gives the wrong answer when a and b are both large and have opposite signs. Jay.