Bug #10086 ยป Remove_Float#power_from_mathn.patch
lib/mathn.rb | ||
---|---|---|
182 | 182 |
module_function :sqrt |
183 | 183 |
module_function :rsqrt |
184 | 184 |
end |
185 | ||
186 |
## |
|
187 |
# When mathn is required, Float is changed to handle Complex numbers. |
|
188 | ||
189 |
class Float |
|
190 |
alias power! ** |
|
191 | ||
192 |
## |
|
193 |
# Exponentiate by +other+ |
|
194 | ||
195 |
def ** (other) |
|
196 |
if self < 0 && other.round != other |
|
197 |
Complex(self, 0.0) ** other |
|
198 |
else |
|
199 |
power!(other) |
|
200 |
end |
|
201 |
end |
|
202 | ||
203 |
end |