Module: Math
- Defined in:
- lib/mark_facets/ruby/math.rb
Class Method Summary collapse
- .log2(x) ⇒ Object
- .logBase(x, base) ⇒ Object
- .max(a, b) ⇒ Object
- .min(a, b) ⇒ Object
- .percentage(n1, n2) ⇒ Object
Class Method Details
.log2(x) ⇒ Object
3 4 5 |
# File 'lib/mark_facets/ruby/math.rb', line 3 def self.log2(x) self.logBase(x, 2.0) end |
.logBase(x, base) ⇒ Object
7 8 9 |
# File 'lib/mark_facets/ruby/math.rb', line 7 def self.logBase(x, base) self.log(x) / self.log(base) end |
.max(a, b) ⇒ Object
15 16 17 |
# File 'lib/mark_facets/ruby/math.rb', line 15 def self.max(a, b) a > b ? a : b end |
.min(a, b) ⇒ Object
11 12 13 |
# File 'lib/mark_facets/ruby/math.rb', line 11 def self.min(a, b) a < b ? a : b end |
.percentage(n1, n2) ⇒ Object
19 20 21 22 23 |
# File 'lib/mark_facets/ruby/math.rb', line 19 def self.percentage(n1, n2) return 0 if n2 == 0 || n1 == 0 p = ((n2.to_f / n1.to_f) * 100) return p end |