mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
de2e8838ae
Replace the traditional Euclidean GCD algorithm with Stein's binary GCD algorithm for improved performance on large numbers: - Implement binary GCD (Stein's algorithm) avoiding expensive division operations - Use bit shifts and subtraction instead of modulo operations - Handle special cases (zero values) efficiently - Preserve common factors of 2 for correct results - Maintain full compatibility with existing rational number functionality Binary GCD is significantly faster for large numbers as it avoids the costly division operations used in the Euclidean algorithm, using only bit operations, addition, and subtraction. Co-authored-by: Claude <noreply@anthropic.com>