diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-09-04 07:54:17 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 18:20:17 +0900 |
| commit | fe3c3bb661aac19761dcb446935d605a946065b9 (patch) | |
| tree | 46746a0ead893a0ab3ddb18c19952f44f8fda954 /mrbgems/mruby-rational/mrblib/rational.rb | |
| parent | f9e781d83a5f50c70a238cbb2f06878c30490146 (diff) | |
| download | mruby-fe3c3bb661aac19761dcb446935d605a946065b9.tar.gz mruby-fe3c3bb661aac19761dcb446935d605a946065b9.zip | |
Made `Rational` overhaul.
- Implement `Rational()` in `C`.
- Use `float` to `rational` conversion function taken from:
https://rosettacode.org/wiki/Convert_decimal_number_to_rational#C
Diffstat (limited to 'mrbgems/mruby-rational/mrblib/rational.rb')
| -rw-r--r-- | mrbgems/mruby-rational/mrblib/rational.rb | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/mrbgems/mruby-rational/mrblib/rational.rb b/mrbgems/mruby-rational/mrblib/rational.rb index e401b1bd6..febabbae7 100644 --- a/mrbgems/mruby-rational/mrblib/rational.rb +++ b/mrbgems/mruby-rational/mrblib/rational.rb @@ -82,13 +82,6 @@ class Numeric end module Kernel - def Rational(numerator, denominator = 1) - a = numerator - b = denominator - a, b = b, a % b until b == 0 - Rational._new(numerator.div(a), denominator.div(a)) - end - [:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op| original_operator_name = :"__original_operator_#{op}_rational" Integer.instance_eval do |
