[前][次][番号順一覧][スレッド一覧]

ruby-changes:8077

From: tadf <ko1@a...>
Date: Sun, 28 Sep 2008 09:42:00 +0900 (JST)
Subject: [ruby-changes:8077] Ruby:r19603 (trunk): * lib/mathn.rb ({Fixnum,Bignum,Float}#**): may produce complex

tadf	2008-09-28 09:41:42 +0900 (Sun, 28 Sep 2008)

  New Revision: 19603

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19603

  Log:
    * lib/mathn.rb ({Fixnum,Bignum,Float}#**): may produce complex
      value.

  Modified files:
    trunk/ChangeLog
    trunk/lib/mathn.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19602)
+++ ChangeLog	(revision 19603)
@@ -1,3 +1,8 @@
+Sun Sep 28 09:39:48 2008  Tadayoshi Funaba  <tadf@d...>
+
+	* lib/mathn.rb ({Fixnum,Bignum,Float}#**): may produce complex
+	  value.
+
 Sun Sep 28 09:05:53 2008  James Edward Gray II  <jeg2@r...>
 
 	* lib/csv/csv.rb:  Worked around some minor encoding changes in Ruby
Index: lib/mathn.rb
===================================================================
--- lib/mathn.rb	(revision 19602)
+++ lib/mathn.rb	(revision 19603)
@@ -61,6 +61,16 @@
   remove_method :/
   alias / quo
 
+  alias power! **
+
+  def ** (other)
+    if self < 0 && other.round != other
+      Complex(self, 0.0) ** other
+    else
+      power!(other)
+    end
+  end
+
   def_canon *(instance_methods - Object.methods - [:canon])
 
 end
@@ -69,6 +79,16 @@
   remove_method :/
   alias / quo
 
+  alias power! **
+
+  def ** (other)
+    if self < 0 && other.round != other
+      Complex(self, 0.0) ** other
+    else
+      power!(other)
+    end
+  end
+
   def_canon *(instance_methods - Object.methods - [:canon])
 
 end
@@ -261,4 +281,14 @@
 
   def_canon *(instance_methods - Object.methods - [:canon])
 
+  alias power! **
+
+  def ** (other)
+    if self < 0 && other.round != other
+      Complex(self, 0.0) ** other
+    else
+      power!(other)
+    end
+  end
+
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]