AI Engine Intrinsics User Guide (AIE) v2024.2
|
Support for converting floating-point numbers to fixed-point and fixed-point numbers to floating-point. More...
Support for converting floating-point numbers to fixed-point and fixed-point numbers to floating-point.
These intrinsics can generate exceptions, for more information you can go here.
Functions | |
float | fix2float (int n) |
Fixed-point to Floating-point conversion without scaling. | |
float | fix2float (int n, int sft) |
Fixed-point to Floating-point conversion with scaling. | |
int | float2fix (float n) |
Floating-point to Fixed-point conversion without scaling. | |
int | float2fix (float n, int sft) |
Floating-point to Fixed-point conversion with scaling. | |
float fix2float | ( | int | n | ) |
Fixed-point to Floating-point conversion without scaling.
n | Integer input value |
float fix2float | ( | int | n, |
int | sft | ||
) |
Fixed-point to Floating-point conversion with scaling.
n | Integer input value |
sft | Binary point of input value. Range [-32:31]. |
If the input value has 8 fractional bits, then 0.5 in fixed point will be expressed as 128. To convert this value to float use the following code, which stores 0.5 in floating-point variable b:
int n = 128; float b = fix2float(n,8);
int float2fix | ( | float | n | ) |
Floating-point to Fixed-point conversion without scaling.
n | Floating point input value |
int float2fix | ( | float | n, |
int | sft | ||
) |
Floating-point to Fixed-point conversion with scaling.
n | Floating point input value |
sft | Binary point of output value. Range [-32:31]. |
The input value is 0.5 and the output shall be of format Q24.8 (meaning 8 fractional bits out of 128 bit integer output word). To convert this value to float use the following code, which stores 128 in fixed-point variable a:
float n = 0.5; int a = float2fix(n,8);