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/ › round.zig › roundq
roundq
round.roundq
pub fn roundq (x_ : f128 ) callconv (.c ) f128
File
Code
pub fn roundq (x_ : f128 ) callconv (.c ) f128 {
const f128_toint = 1.0 / math .floatEps (f128 );
var x = x_ ;
const u : u128 = @bitCast (x );
const e = (u >> 112 ) & 0x7FFF ;
var y : f128 = undefined ;
if (e >= 0x3FFF + 112 ) {
return x ;
}
if (u >> 127 != 0 ) {
x = -x ;
}
if (e < 0x3FFF - 1 ) {
if (compiler_rt .want_float_exceptions ) mem .doNotOptimizeAway (x + f128_toint );
return 0 * @as (f128 , @bitCast (u ));
}
y = x + f128_toint - f128_toint - x ;
if (y > 0.5 ) {
y = y + x - 1 ;
} else if (y <= -0.5 ) {
y = y + x + 1 ;
} else {
y = y + x ;
}
if (u >> 127 != 0 ) {
return -y ;
} else {
return y ;
}
}