ZHCU820Y September 2004 – June 2021
The following intrinsics extract the bits in a floating value or pack bits into a floating value. No instructions or movement of data is performed; these intrinsics tell the compiler how to interpret the bits in place. See Section 7.8.1 for calling syntax.
The following function extracts the sign bit of a float. It does this by using the __f32_bits_as_u32 intrinsic to interpret a float as a 32-bit register. This intrinsic does not move the bits stored in x; it tells the compiler to change how it interprets the bits in place.
bool sign_bit_set(float x) {
return __f32_bits_as_u32(x) >> 31;
}
Another way to use these intrinsics is for converting a float constant that has more precision than needed to a value that has all zero bits in the least significant mantissa bits. This enables the compiler to use one instruction instead of two to load a 32-bit constant into a register. The following code truncates a constant:
__u32_bits_as_f32(__f32_bits_as_u32(3.14159f) & 0xffff0000)