Function log1p [src]
Alias for std.math.log1p.log1p
Returns the natural logarithm of 1 + x with greater accuracy when x is near zero.
Special Cases:
log1p(+inf) = +inf
log1p(+-0) = +-0
log1p(-1) = -inf
log1p(x) = nan if x < -1
log1p(nan) = nan
Prototype
pub fn log1p(x: anytype) @TypeOf(x)
Example
test log1p {
try expect(log1p(@as(f32, 0.0)) == log1p_32(0.0));
try expect(log1p(@as(f64, 0.0)) == log1p_64(0.0));
}
Source
pub fn log1p(x: anytype) @TypeOf(x) {
const T = @TypeOf(x);
return switch (T) {
f32 => log1p_32(x),
f64 => log1p_64(x),
else => @compileError("log1p not implemented for " ++ @typeName(T)),
};
}