pub fn mantissaTop(x: anytype) u16 x46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 pub fn mantissaTop(x: anytype) u16 {
const bit_width = bitWidth(x);
switch (bit_width) {
80 => {
const bits: U80 = @bitCast(x);
return @intCast((bits >> 48) & 0xFFFF);
},
128 => {
const bits: u128 = @bitCast(x);
return @intCast((bits >> 96) & 0xFFFF);
},
// `c_longdouble` can have <80 bits on some targets, we want to error on that
else => @compileError(std.fmt.comptimePrint("`mantissaTop` supports floats of only `80` and `128` bit width, got bit width: {d}", .{bit_width})),
}
}
Takes the top 16 bits of a
long double's mantissa.