To convert from floating-point to fixed-point, we follow this algorithm:
- Calculate x = floating_input * 2^(fractional_bits)
- Round x to the nearest whole number (e.g. round(x) )
- Store the rounded x in an integer container.
How do you change a floating-point to a fixed-point in MATLAB?
You can convert floating-point MATLAB® code to fixed-point code using the Fixed-Point Converter app or at the command line using the fiaccel function -float2fixed option. You can choose to propose data types based on simulation range data, derived (also known as static) range data, or both.
What is fixed-point conversion?
In computing, fixed-point is a method of representing fractional (non-integer) numbers by storing a fixed number of digits of their fractional part. Dollar amounts, for example, are often stored with exactly two fractional digits, representing the cents (1/100 of dollar).