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/ › extendxftf2.zig
extendxftf2.zig
Index
File
Code
const std = @import ("std" );
const symbol = @import ("../compiler_rt.zig" ).symbol ;
comptime {
symbol (&__extendxftf2 , "__extendxftf2" );
}
fn __extendxftf2 (a : f80 ) callconv (.c ) f128 {
const src_int_bit : u64 = 0x8000000000000000 ;
const src_sig_mask = ~src_int_bit ;
const src_sig_bits = std .math .floatMantissaBits (f80 ) - 1 ;
const dst_sig_bits = std .math .floatMantissaBits (f128 );
const dst_bits = @bitSizeOf (f128 );
var a_rep = std .math .F80 .fromFloat (a );
const sign = a_rep .exp & 0x8000 ;
a_rep .exp &= 0x7FFF ;
var abs_result : u128 = undefined ;
if (a_rep .exp == 0 and a_rep .fraction == 0 ) {
abs_result = 0 ;
} else if (a_rep .exp == 0x7FFF ) {
abs_result = @as (u128 , a_rep .fraction ) << (dst_sig_bits - src_sig_bits );
abs_result |= @as (u128 , a_rep .exp ) << dst_sig_bits ;
} else if (a_rep .fraction & src_int_bit != 0 ) {
abs_result = @as (u128 , a_rep .fraction & src_sig_mask ) << (dst_sig_bits - src_sig_bits );
abs_result |= @as (u128 , a_rep .exp ) << dst_sig_bits ;
} else {
abs_result = @as (u128 , a_rep .fraction ) << (dst_sig_bits - src_sig_bits );
}
const result : u128 align (@alignOf (f128 )) = abs_result | @as (u128 , sign ) << (dst_bits - 16 );
return @bitCast (result );
}