End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Math.log10
Math.log10(x) → Float
math.c
View on GitHub ↗
static VALUE
math_log10(VALUE unused_obj, VALUE x)
{
size_t numbits;
double d = get_double_rshift(x, &numbits);
/* check for domain error */
if (d < 0.0) domain_error("log10");
/* check for pole error */
if (d == 0.0) return DBL2NUM(-HUGE_VAL);
return DBL2NUM(log10(d) + numbits * log10(2)); /* log10(d * 2 ** numbits) */
}
Returns the base 10 logarithm of x.
Domain: (0, INFINITY)
Codomain: (-INFINITY, INFINITY)
Example
Math.log10(1) #=> 0.0 Math.log10(10) #=> 1.0 Math.log10(10**100) #=> 100.0