**Overview**

Fixed point numbers are used for representing fractional numbers in digital systems. The term “Fixed-Point” refers to fact that the position of the binary point is always at the same place. The binary point separates the integer and the fractional part of a number (the same as the decimal point in the decimal system).

An** N**-bit binary fixed point number can be generally expressed as X(a, b), where **a **is the number of integer bits and **b **is the number of fractional bits.

For unsigned representation **a** **= N − b**

For signed (two’s complement representation) **a = N – b – 1**

**Example:**

*The binary fixed point number 101.10 can be expressed as X(3,2), where we have 3 bits for the integer part and two bits for the fractional part.*

Binary point represents the coefficient of the term 2^{0} = 1. All bits to the left of the binary point carries a weight of 2^{0}, 2^{1}, 2^{2} etc. The bits on the right of binary point carries a weight of 2^{-1}, 2^{-2}, 2^{-3}, etc.

The fixed-point number 101.10 can be converted to decimal:

1*2^2 + 0 * 2^1 + 1 *2^0 +1*2^-1 + 0 * 2-^2 = 4 + 0 + 1 + 0.5 + 0 = 5.5

A fixed-point number can be defined by its two most informative parameters:

**Range**: The difference between the most negative number representable and the most positive number representable. For example signed number X(13,2) has 13+2+1=16 bits and the range is 16383.75. (from −2^13 = −8192 to +2^13 − 1/4 = 8191.75.)**Resolution: T**he smallest non-zero magnitude representable. For example, a X(13,2) has a resolution of 1/2^2 = 0.25. Resolution depends on the number of bits for the fractional part.

**Fixed-point representation using scaling factors**

We can say that integer representation is a special case of fixed point numbers, where the binary point is at position 0. All arithmetic operations on fixed point numbers are the same as integer. No need for special hardware handling fixed-point arithmetic.

To convert a fractional number to a fixed-point representation we can multiply the number by a scaling factor and round it to an integer.

`fixed_point_value = round(floating_point_value * scaling_factor)`

**Example:**

*The value 6.54 can be represented as 6540 in a fixed-point data type with scaling factor of 1/1000.*

*The value 6,540,000 can be represented as 654 with a scaling factor of 1000. *

Keep in mind that in order to produce correct results when doing arithmetic operations, the scaling factor for the data should be the same.

## Leave A Comment