Base-ten logarithm
Count the number of tenfold steps between one and a positive value.
@log10
Simple example
How many tenfold steps lead to one hundred?
Start100
Result2
const std = @import("std");
pub fn main() !void {
std.debug.print("{d}\n", .{@log10(@as(f64, 100.0))});
}
2
Advertisements
Everyday examples
A map display offers zoom factors of 1, 10 and 1000. Which power of ten is the last setting?
Start1000
Result3
const std = @import("std");
pub fn main() !void {
std.debug.print("{d}\n", .{@log10(@as(f64, 1000.0))});
}
3
A light meter reads ten times its reference. How many tenfold steps is that?
Start10
Result1
const std = @import("std");
pub fn main() !void {
std.debug.print("{d}\n", .{@log10(@as(f64, 10.0))});
}
1
A graph marks a value of 10000 on a base-ten scale. Which exponent belongs on the axis?
Start10000
Result4
const std = @import("std");
pub fn main() !void {
std.debug.print("{d}\n", .{@log10(@as(f64, 10000.0))});
}
4