The range of a number gives the limits of the representation, while the precision gives the distance between successive numbers in the representation. The range and precision of a fixedpoint number depend on the length of the word and the scaling.
You must pay attention to the precision and range of the fixedpoint data types and scalings you choose in order to know whether rounding methods will be invoked or if overflows or underflows will occur.
The range is the span of numbers that a fixedpoint data type and scaling can represent. Range is limited because fixedpoint words have limited size.
The range of representable numbers for a two's complement fixedpoint number of word length $$wl$$, scaling $$S$$ and bias $$B$$ is illustrated below, where the values of $$wl$$, $$S$$, and $$B$$ allow for both negative and positive numbers.
For both signed and unsigned fixedpoint numbers of any data type, the number of different bit patterns is 2^{wl}.
For example, in two's complement, negative numbers must be represented as well as zero, so the maximum value is 2^{wl 1} – 1. Because there is only one representation for zero, there are an unequal number of positive and negative numbers. This means there is a representation for $${2}^{wl1}$$ but not for $${2}^{wl1}$$:
Because a fixedpoint data type represents numbers within a finite range, overflows and underflows can occur if the result of an operation is larger or smaller than the numbers in that range.
In binary arithmetic, a processor might need to take an nbit fixedpoint number and
store it in m bits, where $$m\ne n$$. If m < n, the range of the number has been reduced and an operation
can produce an overflow condition. Some processors identify this condition as
Inf
or NaN
. For other processors, especially
digital signal processors (DSPs), the value saturates or
wraps.
FixedPoint Designer™ software allows you to either saturate or wrap overflows. Saturation represents positive overflows as the largest positive number in the range being used, and negative overflows as the largest negative number in the range being used. Wrapping uses modulo arithmetic to cast an overflow back into the representable range of the data type.
When you create a fi
object, any overflows are saturated. The
OverflowAction
property of the default fimath is
saturate
. You can log overflows and underflows by setting the
LoggingMode
property of the fipref
object to
on
. Refer to LoggingMode for more information.
If m > n, the range of the number has been extended. Extending the range of a word requires the inclusion of guard bits, which act to guard against potential overflow.
The Simulink^{®} software supports saturation and wrapping for all fixedpoint data types, while guard bits are supported only for fractional data types.
The precision of a fixedpoint number is the difference between successive values representable by its data type and scaling. The value of the least significant bit, and therefore the precision of the number, is determined by the number of fractional bits. A fixedpoint value can be represented to within half of the precision of its data type and scaling.
For example, a fixedpoint representation with four bits to the right of the binary point has a precision of 2^{4} or 0.0625, which is the value of its least significant bit. Any number within the range of this data type and scaling can be represented to within (2^{4})/2 or 0.03125, which is half the precision. This is an example of representing a number with finite precision.
The precision of a fixedpoint word depends on the word size and binary point location. For example, suppose you must represent the realworld number 35.375 with a fixedpoint number. Using a slope bias encoding scheme, the representation is
$$V\approx \tilde{V}=SQ+B={2}^{2}Q+32,$$
where V = 35.375.
The two closest approximations to the realworld value are Q = 13 and Q = 14:
$$\begin{array}{l}\tilde{V}={2}^{2}\left(13\right)+32=35.25,\\ \tilde{V}={2}^{2}\left(14\right)+32=\mathrm{35.50.}\end{array}$$
In either case, the absolute error is the same:
$$\left\tilde{V}V\right=0.125=\frac{S}{2}=\frac{F{2}^{E}}{2}.$$
For fixedpoint values within the limited range, this represents the worstcase error if roundtonearest is used. If other rounding modes are used, the worstcase error can be twice as large:
$$\left\tilde{V}V\right<F{2}^{E}.$$
Extending the precision of a word can be accomplished with more bits, but you face practical limitations with this approach. Instead, you must carefully select the data type, word size, and scaling such that numbers are accurately represented. Rounding and padding with trailing zeros are typical methods implemented on processors to deal with the precision of binary words.
The low limit, high limit, and default binarypointonly scaling for the supported fixedpoint data types discussed in BinaryPointOnly Scaling are given in the following table.
FixedPoint Data Type Range and Default Scaling
Name  Data Type  Low Limit  High Limit  Default Scaling (~Precision) 

Unsigned Integer 
 0  $${2}^{ws}1$$ 

Signed Integer 
 $${2}^{ws1}$$  $${2}^{ws1}1$$ 

Unsigned Binary Point 
 0  $$({2}^{ws}1){2}^{fl}$$  $${2}^{fl}$$ 
Signed Binary Point 
 $${2}^{ws1fl}$$  $$({2}^{ws1}1){2}^{fl}$$  $${2}^{fl}$$ 
Unsigned Slope Bias 

 $$s({2}^{ws}1)+b$$  s 
Signed Slope Bias 
 $$s({2}^{ws1})+b$$  $$s({2}^{ws1}1)+b$$  s 
s = Slope, b = Bias, ws = WordLength, fl = FractionLength
The precisions, range of signed values, and range of unsigned values for an 8bit generalized fixedpoint data type with binarypointonly scaling are listed in the follow table. Note that the first scaling value (2^{1}) represents a binary point that is not contiguous with the word.
Scaling  Precision  Range of Signed Values (Low, High)  Range of Unsigned Values (Low, High) 

2^{1}  2.0  256, 254  0, 510 
2^{0}  1.0  128, 127  0, 255 
2^{1}  0.5  64, 63.5  0, 127.5 
2^{2}  0.25  32, 31.75  0, 63.75 
2^{3}  0.125  16, 15.875  0, 31.875 
2^{4}  0.0625  8, 7.9375  0, 15.9375 
2^{5}  0.03125  4, 3.96875  0, 7.96875 
2^{6}  0.015625  2, 1.984375  0, 3.984375 
2^{7}  0.0078125  1, 0.9921875  0, 1.9921875 
2^{8}  0.00390625  0.5, 0.49609375  0, 0.99609375 
The precision and ranges of signed and unsigned values for an
8bit fixedpoint data type using slope and bias scaling are listed
in the following table. The slope starts at a value of 1.25
with
a bias of 1.0
for all slopes. Note that the slope
is the same as the precision.
Bias  Slope/Precision  Range of Signed Values (low, high)  Range of Unsigned Values (low, high) 

1  1.25  159, 159.75  1, 319.75 
1  0.625  79, 80.375  1, 160.375 
1  0.3125  39, 40.6875  1, 80.6875 
1  0.15625  19, 20.84375  1, 40.84375 
1  0.078125  9, 10.921875  1, 20.921875 
1  0.0390625  4, 5.9609375  1, 10.9609375 
1  0.01953125  1.5, 3.48046875  1, 5.98046875 
1  0.009765625  0.25, 2.240234375  1, 3.490234375 
1  0.0048828125  0.375, 1.6201171875  1, 2.2451171875 