# I need fixed point calculation in brief for fixdt(0/1,wl,slope,bias) defination?

5 views (last 30 days)
Ankita Pingale on 5 Mar 2019
Edited: Andy Bartlett on 2 Aug 2022
I want detail calculation of fixed point toolbox how it scales , adjust the slope and bias etc.

Andy Bartlett on 2 Aug 2022
Edited: Andy Bartlett on 2 Aug 2022
Fixed-Point Scaling Equation
real_world_value = (slope * stored_integer_value) + bias
Let's distinguish
real_world_value_original
real_world_value_quantized
Using the Fixed-Point Scaling Equation, let's solve for the "ideal" stored integer given the original real world value
stored_integer_value_IDEAL = ( real_world_value - bias ) / slope
This "ideal" value needs to first be rounded to an integer value. The rounding method is user controllable.
Let's suppose the choice is Floor, so the next step is to produce an integer
stored_integer_value_RANGE_NOT_YET_LIMITED = rounding_action( ( real_world_value - bias ) / slope )
Next, the stored integer must be limited to the range of the underlying storage container.
For example, if the underlying container is signed 8-bits, then the integer must be in the range -128 to +127.
If the stored integer value after rounding is out of range, then an overflow has occurred.
Overflow handling is also user controllable. Out of range values can be saturated to the representable range or wrapped around modulo 2^nBits, like the hands on a clock. After the overflow handling step the final stored integer is determined.
stored_integer_value = overflow_action( rounding_action( ( real_world_value - bias ) / slope ) )
This stored integer value is the raw value that will appear in the memory of the embedded system.
To understand what this means in the real world, the Fixed-Point Scaling Equation comes back into play.
real_world_value_quantized = (slope * stored_integer_value) + bias
quantization_error = real_world_value_quantized - real_world_value_original
Experiments with fi objects are easy
In MATLAB, it's easy to experiment with quantization impacts by using the fi object.
By simply calling fi, we can see how pi is getting quantized.
rwv_orig = pi
rwv_quantized = fi( rwv_orig, fixdt(1,8,5), 'RoundingMethod', 'Floor' )
quantization_error = double(rwv_quantized) - rwv_orig
which outputs
rwv_orig =
3.1416
rwv_quantized =
3.1250
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 8
FractionLength: 5
RoundingMethod: Floor
OverflowAction: Saturate
ProductMode: FullPrecision
SumMode: FullPrecision
quantization_error =
-0.0166