Class: Numeric

Inherits:
Object show all
Defined in:
lib/darkext/numeric.rb

Instance Method Summary collapse

Instance Method Details

#cubeObject

Cube the number



10
11
12
# File 'lib/darkext/numeric.rb', line 10

def cube
  self.square * self
end

#lnObject

Finds the log base e of the number



27
28
29
# File 'lib/darkext/numeric.rb', line 27

def ln
  Math::log(self)
end

#logObject

Finds the log base 10 of the number



32
33
34
# File 'lib/darkext/numeric.rb', line 32

def log
  Math::log10(self)
end

#root(n = 2) ⇒ Object

Do some other roots



20
21
22
23
24
# File 'lib/darkext/numeric.rb', line 20

def root(n = 2)
  return self if 1 == n
  return self.sqrt if 2 == n
  self ** (1 / n.to_f)
end

#sqrtObject

Finds the square root of the number



15
16
17
# File 'lib/darkext/numeric.rb', line 15

def sqrt
  Math.sqrt(self)
end

#squareObject

Squares the number



5
6
7
# File 'lib/darkext/numeric.rb', line 5

def square
  self * self
end