Bug #175
Rational#power2 raises a NameError or causes infinite loops when passed a Rational
| Status: | Closed | Start date: | 06/17/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | - | |||
| ruby -v: |
Description
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
Associated revisions
* lib/mathn.rb (Rational::power2): typo fixed. [ruby-core:17293]
History
Updated by Anonymous over 3 years ago
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
Updated by Yukihiro Matsumoto over 3 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r17449.
Updated by Arthur Schreiber over 3 years ago
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
Updated by Yukihiro Matsumoto over 3 years ago
- Status changed from Closed to Assigned
- Assignee set to Yukihiro Matsumoto
- % Done changed from 100 to 0
Updated by Yukihiro Matsumoto over 3 years ago
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 <redmine@ruby-lang.org> 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.
Updated by Yukihiro Matsumoto over 3 years ago
- Status changed from Assigned to Closed