Project

General

Profile

Bug #10086 ยป Remove_Fixnum#power_from_mathn.patch

gogotanaka (Kazuki Tanaka), 07/23/2014 11:58 AM

View differences:

lib/mathn.rb
53 53
end
54 54
##
55
# When mathn is required, Fixnum's division and exponentiation are enhanced to
55
# When mathn is required, Fixnum's division is enhanced to
56 56
# return more precise values from mathematical expressions.
57 57
#
58 58
#   2/3*3  # => 0
......
62 62
class Fixnum
63 63
  remove_method :/
64

  
65
  ##
66
  # +/+ defines the Rational division for Fixnum.
67
  #
68
  #   1/3  # => (1/3)
69

  
70
  alias / quo
71

  
72
  alias power! ** unless method_defined? :power!
73

  
74
  ##
75
  # Exponentiate by +other+
76

  
77
  def ** (other)
78
    if self < 0 && other.round != other
79
      Complex(self, 0.0) ** other
80
    else
81
      power!(other)
82
    end
83
  end
84

  
64
  alias :/ :quo
85 65
end
86 66
##