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 standard library.
std › math › complex › cosh › cosh32 Private Function cosh32 Doc Source Private Function std.math.complex.cosh.cosh32
fn cosh32 (z : Complex (f32 )) Complex (f32 ) Params File math/complex/cosh.zig: 25
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 fn cosh32 (z : Complex (f32 )) Complex (f32 ) {
const x = z .re ;
const y = z .im ;
const hx : u32 = @bitCast (x );
const ix = hx & 0x7fffffff ;
const hy : u32 = @bitCast (y );
const iy = hy & 0x7fffffff ;
if (ix < 0x7f800000 and iy < 0x7f800000 ) {
if (iy == 0 ) {
return Complex (f32 ).init (math .cosh (x ), x * y );
}
// small x: normal case
if (ix < 0x41100000 ) {
return Complex (f32 ).init (math .cosh (x ) * @cos (y ), math .sinh (x ) * @sin (y ));
}
// |x|>= 9, so cosh(x) ~= exp(|x|)
if (ix < 0x42b17218 ) {
// x < 88.7: exp(|x|) won't overflow
const h = @exp (@abs (x )) * 0.5 ;
return Complex (f32 ).init (h * @cos (y ), math .copysign (h , x ) * @sin (y ));
}
// x < 192.7: scale to avoid overflow
else if (ix < 0x4340b1e7 ) {
const v = Complex (f32 ).init (@abs (x ), y );
const r = ldexp_cexp (v , -1 );
return Complex (f32 ).init (r .re , r .im * math .copysign (@as (f32 , 1.0 ), x ));
}
// x >= 192.7: result always overflows
else {
const h = 0x1p127 * x ;
return Complex (f32 ).init (h * h * @cos (y ), h * @sin (y ));
}
}
if (ix == 0 and iy >= 0x7f800000 ) {
return Complex (f32 ).init (y - y , math .copysign (@as (f32 , 0.0 ), x * (y - y )));
}
if (iy == 0 and ix >= 0x7f800000 ) {
if (hx & 0x7fffff == 0 ) {
return Complex (f32 ).init (x * x , math .copysign (@as (f32 , 0.0 ), x ) * y );
}
return Complex (f32 ).init (x * x , math .copysign (@as (f32 , 0.0 ), (x + x ) * y ));
}
if (ix < 0x7f800000 and iy >= 0x7f800000 ) {
return Complex (f32 ).init (y - y , x * (y - y ));
}
if (ix >= 0x7f800000 and (hx & 0x7fffff ) == 0 ) {
if (iy >= 0x7f800000 ) {
return Complex (f32 ).init (x * x , x * (y - y ));
}
return Complex (f32 ).init ((x * x ) * @cos (y ), x * @sin (y ));
}
return Complex (f32 ).init ((x * x ) * (y - y ), (x + x ) * (y - y ));
}