Typecasting

__STATIC_INLINE int16_t riscv_typecast_s16_f16 (float16_t x)
__STATIC_INLINE float16_t riscv_typecast_f16_s16 (int16_t x)
group typecast

Functions

__STATIC_INLINE int16_t riscv_typecast_s16_f16 (float16_t x)

Interpret a f16 as an s16 value.

Description

It is a typecast. No conversion of the float to int is done. The memcpy will be optimized out by the compiler. memcpy is used to prevent type punning issues. With gcc, -fno-builtins MUST not be used or the memcpy will not be optimized out.

Parameters

x[in] input value.

Returns

return value.

__STATIC_INLINE float16_t riscv_typecast_f16_s16 (int16_t x)

Interpret an s16 as an f16 value.

Description

It is a typecast. No conversion of the int to float is done. The memcpy will be optimized out by the compiler. memcpy is used to prevent type punning issues. With gcc, -fno-builtins MUST not be used or the memcpy will not be optimized out.

Parameters

x[in] input value.

Returns

return value.