mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
5fd8b44502
When converting large numbers to strings using D&C algorithm, the base case extracts digits in batches of 9 (for 32-bit limbs). The extraction logic: 1 leading digit + 4 pairs (8 digits) = 9 digits. The pair extraction loop condition `pos >= 2` exits when pos < 2, but when the remaining batch still has value and pos == 1, that final digit was being lost and replaced with '0' by the padding loop. This caused roundtrip failures (x.to_s.to_i != x) for numbers just above the D&C threshold (1000 digits), where the split boundary produced a lo part requiring exactly the right number of digits to trigger this edge case. Co-authored-by: Claude <noreply@anthropic.com>