Sha256: 23342dba32f2731f07e7597e5ccf2d5a78f21bd7d213e253c4dc5aec1591fd09

Contents?: true

Size: 491 Bytes

Versions: 26

Compression:

Stored size: 491 Bytes

Contents

require 'mathn'

class Numeric
  # Squares the number
  def square
    self * self
  end

  # Cube the number
  def cube
    self.square * self
  end

  # Finds the square root of the number
  def sqrt
    Math.sqrt(self)
  end

  # Do some other roots
  def root(n = 2)
    return self.sqrt if n == 2
    self ** (1 / n.to_f)
  end

  # Finds the log base e of the number
  def ln
    Math::log(self)
  end

  # Finds the log base 10 of the number
  def log
    Math::log10(self)
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
darkhelmet-darkext-0.10.0 lib/darkext/numeric.rb
darkhelmet-darkext-0.11.0 lib/darkext/numeric.rb
darkhelmet-darkext-0.5.3 lib/darkext/numeric.rb
darkhelmet-darkext-0.5.4 lib/darkext/numeric.rb
darkhelmet-darkext-0.5.5 lib/darkext/numeric.rb
darkhelmet-darkext-0.5.6 lib/darkext/numeric.rb
darkhelmet-darkext-0.6.0 lib/darkext/numeric.rb
darkhelmet-darkext-0.7.0 lib/darkext/numeric.rb
darkhelmet-darkext-0.7.1 lib/darkext/numeric.rb
darkhelmet-darkext-0.7.2 lib/darkext/numeric.rb
darkhelmet-darkext-0.7.3 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.0 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.1 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.2 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.3 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.4 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.5 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.6 lib/darkext/numeric.rb
darkhelmet-darkext-0.8.7 lib/darkext/numeric.rb
darkhelmet-darkext-0.9.0 lib/darkext/numeric.rb