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 › compiler_rt/ › rem_pio2f.zig › rem_pio2f
rem_pio2f
rem_pio2f.rem_pio2f
pub fn rem_pio2f (x : f32 , y : *f64 ) i32
File
Code
pub fn rem_pio2f (x : f32 , y : *f64 ) i32 {
var tx : [1 ]f64 = undefined ;
var ty : [1 ]f64 = undefined ;
var @"fn" : f64 = undefined ;
var ix : u32 = undefined ;
var n : i32 = undefined ;
var sign : bool = undefined ;
var e0 : u32 = undefined ;
var ui : u32 = undefined ;
ui = @bitCast (x );
ix = ui & 0x7fffffff ;
if (ix < 0x4dc90fdb ) {
// Use a specialized rint() to get fn.
@"fn" = @as (f64 , @floatCast (x )) * invpio2 + toint - toint ;
n = @intFromFloat (@"fn" );
y .* = x - @"fn" * pio2_1 - @"fn" * pio2_1t ;
if (y .* < -pio4 ) {
n -= 1 ;
@"fn" -= 1 ;
y .* = x - @"fn" * pio2_1 - @"fn" * pio2_1t ;
} else if (y .* > pio4 ) {
n += 1 ;
@"fn" += 1 ;
y .* = x - @"fn" * pio2_1 - @"fn" * pio2_1t ;
}
return n ;
}
if (ix >= 0x7f800000 ) {
y .* = x - x ;
return 0 ;
}
sign = ui >> 31 != 0 ;
e0 = (ix >> 23 ) - (0x7f + 23 );
ui = ix - (e0 << 23 );
tx [0 ] = @as (f32 , @bitCast (ui ));
n = rem_pio2_large (&tx , &ty , @as (i32 , @intCast (e0 )), 1 , 0 );
if (sign ) {
y .* = -ty [0 ];
return -n ;
}
y .* = ty [0 ];
return n ;
}