Project

General

Profile

Actions

Bug #175

closed

Rational#power2 raises a NameError or causes infinite loops when passed a Rational

Added by NoKarma (Arthur Schreiber) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
[ruby-core:17293]

Description

=begin
There is propably a typo in the Rational#power2 method, as there is no variable
called "neaed", but there is one called "neard".

Desktop:~ arthur$ irb
irb(main):001:0> require "mathn"
=> true
irb(main):002:0> Rational(1, 4).power2(Rational(1, 2))
NameError: undefined local variable or method neaed' for 1/4:Rational from /usr/local/lib/ruby/1.8/mathn.rb:204:in power2'
from /usr/local/lib/ruby/1.8/mathn.rb:202:in loop' from /usr/local/lib/ruby/1.8/mathn.rb:202:in power2'
from (irb):2

If you pass a value that is equal to self, it will cause an infinite loop:

Rational(1, 2).power2(Rational(1, 2)) # => Infinite Loop
Rational(1, 4).power2(Rational(1, 4)) # => Infinite Loop
=end

Actions #1

Updated by Anonymous almost 16 years ago

=begin
Why is ruby 1.8.7 not using version 1.5.8 from
http://dev.ctor.org/soap4r? What is the process for including soap4r
changes? Is it tied to nahi?

Just curious ;-)

eTM

=end

Actions #2

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r17449.
=end

Actions #3

Updated by NoKarma (Arthur Schreiber) over 15 years ago

=begin
Rational#power2 is still not working correctly:

Rational(1, 4).power2(Rational(1, 2)) # => NameError: undefined local variable or method `num' for 1/4:Rational

Rational(1, 4).power2(Rational(1, 4)) # => Infinite Loop
Rational(1, 2).power2(Rational(1, 2)) # => Infinite Loop

=end

Actions #4

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Closed to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)
  • % Done changed from 100 to 0

=begin

=end

Actions #5

Updated by matz (Yukihiro Matsumoto) over 15 years ago

=begin
Hi,

In message "Re: [ruby-core:17354] [Ruby 1.8 - Bug #175] Rational#power2 raises a NameError or causes infinite loops when passed a Rational"
on Sat, 21 Jun 2008 00:54:00 +0900, Arthur Schreiber writes:

|Rational#power2 is still not working correctly:

I'll see. But note that power2 is not a part of public API of
Rational.

						matz.

=end

Actions #6

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Assigned to Closed

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0