Skip to content

Commit

Permalink
* lib/mathn.rb ({Fixnum,Bignum,Float}#**): may produce complex
Browse files Browse the repository at this point in the history
	  value.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
tadf committed Sep 28, 2008
1 parent bde8a01 commit 0b99ce1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Sun Sep 28 09:39:48 2008 Tadayoshi Funaba <tadf@dotrb.org>

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

Sun Sep 28 09:05:53 2008 James Edward Gray II <jeg2@ruby-lang.org>

* lib/csv/csv.rb: Worked around some minor encoding changes in Ruby
Expand Down
30 changes: 30 additions & 0 deletions lib/mathn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class Fixnum
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
Expand All @@ -69,6 +79,16 @@ class Bignum
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
Expand Down Expand Up @@ -261,4 +281,14 @@ class Float

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

0 comments on commit 0b99ce1

Please sign in to comment.