method

log10

v1_8_6_287 - Show latest stable - Class: Math
log10(p1)
public

Returns the base 10 logarithm of numeric.

1Note

Any base logarithm

szeryf ยท Jul 13, 2009

Using basic arithmetic you can get logarithm with any base:

def log_with_base base, num
Math.log(num) / Math.log(base)
end

Examples:

>> log_with_base 2, 10
=> 3.32192809488736
>> log_with_base 2, 2
=> 1.0
>> log_with_base 2, 4
=> 2.0
>> log_with_base 2, 16
=> 4.0
>> log_with_base 4, 16
=> 2.0