Documentation Center 
On this page… 

Fixedpoint numbers and their data types are characterized by their word size in bits, binary point, and whether they are signed or unsigned. The FixedPoint Designer™ software supports integers and fixedpoint numbers. The main difference among these data types is their binary point.
A common representation of a binary fixedpoint number , either signed or unsigned, is shown in the following figure.
where
Computer hardware typically represents the negation of a binary fixedpoint number in three different ways: sign/magnitude, one's complement, and two's complement. Two's complement is the preferred representation of signed fixedpoint numbers and supported by the FixedPoint Designer software.
Negation using two's complement consists of a bit inversion (translation into one's complement) followed by the addition of a one. For example, the two's complement of 000101 is 111011.
Whether a fixedpoint value is signed or unsigned is usually not encoded explicitly within the binary word; that is, there is no sign bit. Instead, the sign information is implicitly defined within the computer architecture.
The binary point is the means by which fixedpoint numbers are scaled. It is usually the software that determines the binary point. When performing basic math functions such as addition or subtraction, the hardware uses the same logic circuits regardless of the value of the scale factor. In essence, the logic circuits have no knowledge of a scale factor. They are performing signed or unsigned fixedpoint binary algebra as if the binary point is to the right of b_{0}.
FixedPoint Designer supports the general binary point scaling . V is the realworld value, Q is the stored integer value, and E is equal to FractionLength. In other words, RealWorldValue = StoredInteger * 2 ^ FractionLength.
FractionLength defines the scaling of the stored integer value. The word length limits the values that the stored integer can take, but it does not limit the values FractionLength can take. The software does not restrict the value of exponent E based on the word length of the stored integer Q. Because E is equal to FractionLength, restricting the binary point to being contiguous with the fraction is unnecessary; the fraction length can be negative or greater than the word length.
For example, a word consisting of three unsigned bits is usually represented in scientific notation in one of the following ways.
If the exponent were greater than 0 or less than 3, then the representation would involve lots of zeros.
These extra zeros never change to ones, however, so they don't show up in the hardware. Furthermore, unlike floatingpoint exponents, a fixedpoint exponent never shows up in the hardware, so fixedpoint exponents are not limited by a finite number of bits.
Consider a signed value with a word length of 8, a fraction
length of 10, and a stored integer value of 5 (binary value 00000101).
The realword value is calculated using the formula
RealWorldValue
= StoredInteger * 2 ^ FractionLength. In this case, RealWorldValue
= 5 * 2 ^ 10 = 0.0048828125. Because the fraction length
is 2 bits longer than the word length, the binary value of the stored
integer is x.xx00000101 , where x is
a placeholder for implicit zeros. 0.0000000101 (binary)
is equivalent to 0.0048828125 (decimal). For
an example using a fi object, see Create a fi Object With Fraction Length
Greater Than Word Length.
The dynamic range of fixedpoint numbers is much less than floatingpoint numbers with equivalent word sizes. To avoid overflow conditions and minimize quantization errors, fixedpoint numbers must be scaled.
With the FixedPoint Designer software, you can select a fixedpoint data type whose scaling is defined by its binary point, or you can select an arbitrary linear scaling that suits your needs. This section presents the scaling choices available for fixedpoint data types.
You can represent a fixedpoint number by a general slope and bias encoding scheme
where
V is an arbitrarily precise realworld value.
is the approximate realworld value.
Q, the stored value, is an integer that encodes V.
is the slope.
B is the bias.
The slope is partitioned into two components:
specifies the binary point. E is the fixed poweroftwo exponent.
F is the slope adjustment factor. It is normalized such that .
The scaling modes available to you within this encoding scheme are described in the sections that follow. For detailed information about how the supported scaling modes effect fixedpoint operations, refer to Recommendations for Arithmetic and Scaling.
Binarypointonly or poweroftwo scaling involves moving the binary point within the fixedpoint word. The advantage of this scaling mode is to minimize the number of processor arithmetic operations.
With binarypointonly scaling, the components of the general slope and bias formula have the following values:
F = 1
The scaling of a quantized realworld number is defined by the slope S, which is restricted to a power of two. The negative of the poweroftwo exponent is called the fraction length. The fraction length is the number of bits to the right of the binary point. For BinaryPointOnly scaling, specify fixedpoint data types as
signed types — fixdt(1, WordLength, FractionLength)
unsigned types — fixdt(0, WordLength, FractionLength)
Integers are a special case of fixedpoint data types. Integers have a trivial scaling with slope 1 and bias 0, or equivalently with fraction length 0. Specify integers as
signed integer — fixdt(1, WordLength, 0)
unsigned integer — fixdt(0, WordLength, 0)
When you scale by slope and bias, the slope S and bias B of the quantized realworld number can take on any value. The slope must be a positive number. Using slope and bias, specify fixedpoint data types as
fixdt(Signed, WordLength, Slope, Bias)
Specify fixedpoint data types with an unspecified scaling as
fixdt(Signed, WordLength)
Simulink^{®} signals, parameters, and states must never have unspecified scaling. When scaling is unspecified, you must use some other mechanism such as automatic best precision scaling to determine the scaling that the Simulink software uses.
The quantization Q of a realworld value V is represented by a weighted sum of bits. Within the context of the general slope and bias encoding scheme, the value of an unsigned fixedpoint quantity is given by
while the value of a signed fixedpoint quantity is given by
where
are binary digits, with , for
The word size in bits is given by ws, with ws = 1, 2, 3,..., 128.
S is given by , where the scaling is unrestricted because the binary point does not have to be contiguous with the word.
are called bit multipliers and are called the weights.
Formats for 8bit signed and unsigned fixedpoint values are shown in the following figure.
Note that you cannot discern whether these numbers are signed or unsigned data types merely by inspection since this information is not explicitly encoded within the word.
The binary number 0011.0101 yields the same value for the unsigned and two's complement representation because the MSB = 0. Setting B = 0 and using the appropriate weights, bit multipliers, and scaling, the value is
Conversely, the binary number 1011.0101 yields different values for the unsigned and two's complement representation since the MSB = 1.
Setting B = 0 and using the appropriate weights, bit multipliers, and scaling, the unsigned value is
while the two's complement value is
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.
The following figure illustrates the range of representable numbers for an unsigned fixedpoint number of size ws, scaling S, and bias B.
The following figure illustrates the range of representable numbers for a two's complement fixedpoint number of size ws, scaling S, and bias B where the values of ws, scaling S, and bias B allow for both negative and positive numbers.
For both the signed and unsigned fixedpoint numbers of any data type, the number of different bit patterns is 2^{ws}.
For example, if the fixedpoint data type is an integer with scaling defined as and B = 0, then the maximum unsigned value is , because zero must be represented. In two's complement, negative numbers must be represented as well as zero, so the maximum value is . Additionally, since there is only one representation for zero, there must be an unequal number of positive and negative numbers. This means there is a representation for but not for .
The precision of a data type is given by the slope. In this usage, precision means the difference between neighboring representable values.
The low limit, high limit, and default binarypointonly scaling for the supported fixedpoint data types discussed in Binary Point Interpretation are given in the following table. See Precision and Range for more information.
FixedPoint Data Type Range and Default Scaling
Name  Data Type  Low Limit  High Limit  Default Scaling (~Precision) 

Unsigned Integer  fixdt(0,ws,0)  0 
 1 
Signed Integer  fixdt(1,ws,0) 

 1 
Unsigned Binary Point  fixdt(0,ws,fl)  0 


Signed Binary Point  fixdt(1,ws,fl) 



Unsigned Slope Bias  fixdt(0,ws,s,b)  b 
 s 
Signed Slope Bias  fixdt(1,ws,s,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 