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/ › complex/ › tanh.zig › tanh32
tanh32
tanh.tanh32
fn tanh32 (z : Complex (f32 )) Complex (f32 )
File
Code
fn tanh32 (z : Complex (f32 )) Complex (f32 ) {
const x = z .re ;
const y = z .im ;
const hx = @as (u32 , @bitCast (x ));
const ix = hx & 0x7fffffff ;
if (ix >= 0x7f800000 ) {
if (ix & 0x7fffff != 0 ) {
const r = if (y == 0 ) y else x * y ;
return Complex (f32 ).init (x , r );
}
const xx = @as (f32 , @bitCast (hx - 0x40000000 ));
const r = if (math .isInf (y )) y else @sin (y ) * @cos (y );
return Complex (f32 ).init (xx , math .copysign (@as (f32 , 0.0 ), r ));
}
if (!math .isFinite (y )) {
const r = if (ix != 0 ) y - y else x ;
return Complex (f32 ).init (r , y - y );
}
if (ix >= 0x41300000 ) {
const exp_mx = @exp (-@abs (x ));
return Complex (f32 ).init (math .copysign (@as (f32 , 1.0 ), x ), 4 * @sin (y ) * @cos (y ) * exp_mx * exp_mx );
}
const t = @tan (y );
const beta = 1.0 + t * t ;
const s = math .sinh (x );
const rho = @sqrt (1 + s * s );
const den = 1 + beta * s * s ;
return Complex (f32 ).init ((beta * rho * s ) / den , t / den );
}