Allows to access underlying bits as two equally sized lower and higher signed or unsigned integers.
pub fn HalveInt(comptime T: type, comptime signed_half: bool) type
pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {
return extern union {
pub const bits = @divExact(@typeInfo(T).int.bits, 2);
pub const HalfTU = @Int(.unsigned, bits);
pub const HalfTS = @Int(.signed, bits);
pub const HalfT = if (signed_half) HalfTS else HalfTU;
all: T,
s: if (native_endian == .little)
extern struct { low: HalfT, high: HalfT }
else
extern struct { high: HalfT, low: HalfT },
};
}