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/ › exp.zig › exp32
exp32
exp.exp32
fn exp32 (z : Complex (f32 )) Complex (f32 )
File
Code
fn exp32 (z : Complex (f32 )) Complex (f32 ) {
const exp_overflow = 0x42b17218 ;
const cexp_overflow = 0x43400074 ;
const x = z .re ;
const y = z .im ;
const hy = @as (u32 , @bitCast (y )) & 0x7fffffff ;
if (hy == 0 ) {
return Complex (f32 ).init (@exp (x ), y );
}
const hx = @as (u32 , @bitCast (x ));
if ((hx & 0x7fffffff ) == 0 ) {
return Complex (f32 ).init (@cos (y ), @sin (y ));
}
if (hy >= 0x7f800000 ) {
if ((hx & 0x7fffffff ) != 0x7f800000 ) {
return Complex (f32 ).init (y - y , y - y );
}
else if (hx & 0x80000000 != 0 ) {
return Complex (f32 ).init (0 , 0 );
}
else {
return Complex (f32 ).init (x , y - y );
}
}
if (hx >= exp_overflow and hx <= cexp_overflow ) {
return ldexp_cexp (z , 0 );
}
// - x > cexp_overflow, so exp(x) * s overflows for s > 0
// - x = +-inf
// - x = nan
else {
const exp_x = @exp (x );
return Complex (f32 ).init (exp_x * @cos (y ), exp_x * @sin (y ));
}
}