Files
mruby-mruby/mrbgems/mruby-bigint/core
Yukihiro "Matz" Matsumoto 589f256ffa mruby-bigint: fix carry calculation in MSVC 64-bit multiplication
The MSVC-specific _umul128 code path had incorrect carry propagation
when adding three values (rp[i] + lo + carry). The original code:

  carry = hi + (sum < lo);

only detected overflow between sum and lo, missing overflow in the
first addition rp[i] + lo. This caused incorrect bigint calculations
on VC 64-bit builds.

Fixed by splitting three-way addition into two two-way additions
with proper overflow detection for each step:

  temp = rp_val + lo;
  sum = temp + carry;
  carry = hi + (temp < rp_val) + (sum < temp);

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-23 10:49:50 +09:00
..
2025-05-14 02:01:02 +10:00