Bug #10086 ยป Remove_Bignum#power_from_mathn.patch
lib/mathn.rb | ||
---|---|---|
66 | 66 |
end |
67 | 67 |
## |
68 |
# When mathn is required Bignum's division and exponentiation are enhanced to
|
|
68 |
# When mathn is required Bignum's division is enhanced to
|
|
69 | 69 |
# return more precise values from mathematical expressions. |
70 |
# |
|
71 |
# (2**72) / ((2**70) * 3) # => 4/3 |
|
70 | 72 |
class Bignum |
71 | 73 |
remove_method :/ |
72 | ||
73 |
## |
|
74 |
# +/+ defines the Rational division for Bignum. |
|
75 |
# |
|
76 |
# (2**72) / ((2**70) * 3) # => 4/3 |
|
77 | ||
78 |
alias / quo |
|
79 | ||
80 |
alias power! ** unless method_defined? :power! |
|
81 | ||
82 |
## |
|
83 |
# Exponentiate by +other+ |
|
84 | ||
85 |
def ** (other) |
|
86 |
if self < 0 && other.round != other |
|
87 |
Complex(self, 0.0) ** other |
|
88 |
else |
|
89 |
power!(other) |
|
90 |
end |
|
91 |
end |
|
92 | ||
74 |
alias :/ :quo |
|
93 | 75 |
end |
94 | 76 |
## |