mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
990ff90fb4
For base-10 conversion of numbers with >1000 digits, use a recursive divide-and-conquer algorithm that splits the number using precomputed powers of 10. This reduces complexity from O(n^2) to O(n log^2 n). The algorithm: 1. Precompute 10^1, 10^2, 10^4, 10^8, ... by repeated squaring 2. Find the largest power that splits digits roughly in half 3. Divide by this power to get high and low parts 4. Recursively convert each part, padding low part with zeros 5. Base case: use simple divide-by-10 for <= 1000 digits Co-authored-by: Claude <noreply@anthropic.com>