Bug #10086 » Remove_Fixnum#power_from_mathn.patch
| lib/mathn.rb | ||
|---|---|---|
|
end
|
||
|
##
|
||
|
# When mathn is required, Fixnum's division and exponentiation are enhanced to
|
||
|
# When mathn is required, Fixnum's division is enhanced to
|
||
|
# return more precise values from mathematical expressions.
|
||
|
#
|
||
|
# 2/3*3 # => 0
|
||
| ... | ... | |
|
class Fixnum
|
||
|
remove_method :/
|
||
|
##
|
||
|
# +/+ defines the Rational division for Fixnum.
|
||
|
#
|
||
|
# 1/3 # => (1/3)
|
||
|
alias / quo
|
||
|
alias power! ** unless method_defined? :power!
|
||
|
##
|
||
|
# Exponentiate by +other+
|
||
|
def ** (other)
|
||
|
if self < 0 && other.round != other
|
||
|
Complex(self, 0.0) ** other
|
||
|
else
|
||
|
power!(other)
|
||
|
end
|
||
|
end
|
||
|
alias :/ :quo
|
||
|
end
|
||
|
##
|
||