Actions
Bug #141
closedRational#power2 loops when the argument is 0
Description
=begin
Rational#power2, when passed Rational, loop if the argument is 0.
For example:
Rational.new!(3, 4).power2(Rational.new!(0, 3))
=end
Updated by shyouhei (Shyouhei Urabe) over 16 years ago
=begin
Gianluigi Spagnuolo wrote:
Rational#power2, when passed Rational, loop if the argument is 0.
For example:
Rational.new!(3, 4).power2(Rational.new!(0, 3))
That's because you're using unrecommended new! and undocumented power2,
both are not expected to be used.
Rational(3, 4) ** Rational(0, 3) should return immediately.
Index: lib/mathn.rb¶
--- lib/mathn.rb (revision 17088)
+++ lib/mathn.rb (working copy)
@@ -186,6 +186,7 @@
def power2(other)
if other.kind_of?(Rational)
-
other = Rational.reduce(other.numerator, other.denominator) if self < 0 return Complex(self, 0) ** other elsif other == 0
=end
Updated by matz (Yukihiro Matsumoto) over 16 years ago
- Status changed from Open to Closed
- Assignee set to matz (Yukihiro Matsumoto)
=begin
=end
Actions
Like0
Like0Like0