diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-20 00:15:36 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-20 00:15:36 +0000 |
commit | f816b8b167ae60d266172d9eb6544990cbc228b7 (patch) | |
tree | bed9af95f46cc8647c5126fa9c0ae0c91afc84e2 /lib/rational.rb | |
parent | a6c936c15b2145b2a4219e2503301e5cd167f3e2 (diff) |
* lib/webrick/httpservlet/cgihandler.rb (WEBrick::HTTPServlet::CGIHandler):
qualify the access for Config constant. [ruby-dev:28338]
* lib/resolv.rb (Resolv::DNS::Resource::IN::A): qualify
ClassValue. [ruby-dev:28338]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rational.rb')
-rw-r--r-- | lib/rational.rb | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/lib/rational.rb b/lib/rational.rb index fd5bc95a34..45bd141c8d 100644 --- a/lib/rational.rb +++ b/lib/rational.rb @@ -435,42 +435,16 @@ class Integer # The result is positive, no matter the sign of the arguments. # def gcd(n) - m = self.abs - n = n.abs - - return n if m == 0 - return m if n == 0 - - b = 0 - while n[0] == 0 && m[0] == 0 - b += 1; n >>= 1; m >>= 1 - end - m >>= 1 while m[0] == 0 - n >>= 1 while n[0] == 0 - while m != n - m, n = n, m if n > m - m -= n; m >>= 1 while m[0] == 0 - end - m << b - end - - def gcd2(int) - a = self.abs - b = int.abs - - a, b = b, a if a < b - - while b != 0 - void, a = a.divmod(b) - a, b = b, a + min = self.abs + max = other.abs + while min > 0 + tmp = min + min = max % min + max = tmp end - return a + max end - # - # Returns the <em>lowest common multiple</em> (LCM) of the two arguments - # (+self+ and +other+). - # # Examples: # 6.lcm 7 # -> 42 # 6.lcm 9 # -> 18 |