Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › math/ › tanh.zig › tanh64
tanh64
tanh.tanh64
fn tanh64 (x : f64 ) f64
File
Code
fn tanh64 (x : f64 ) f64 {
const u = @as (u64 , @bitCast (x ));
const ux = u & 0x7FFFFFFFFFFFFFFF ;
const w = @as (u32 , @intCast (ux >> 32 ));
const ax = @as (f64 , @bitCast (ux ));
const sign = (u >> 63 ) != 0 ;
var t : f64 = undefined ;
if (w > 0x3FE193EA ) {
if (w > 0x40340000 ) {
t = 1.0 - 0 / ax ;
} else {
t = math .expm1 (2 * ax );
t = 1 - 2 / (t + 2 );
}
}
else if (w > 0x3FD058AE ) {
t = math .expm1 (2 * ax );
t = t / (t + 2 );
}
else if (w >= 0x00100000 ) {
t = math .expm1 (-2 * ax );
t = -t / (t + 2 );
}
else {
mem .doNotOptimizeAway (@as (f32 , @floatCast (ax )));
t = ax ;
}
return if (sign ) -t else t ;
}