Representation of fractions


To represent fractions may be necessary quite often inside the computer. For example, it may be needed to represent inside a computer a value like +0.610 or -0.610. To represent signed fractions, it is necessary to assume the binary point just after the MSB in the bit sequence. Such numbers where the binary point is assumed to be at a fixed position in the bit sequence are called fixed-point numbers.

Unsigned fractions will have the assumed binary point at the extreme left. SM,1's complement, and 2's complement fractions will have this imaginary binary point just to the right of the MS bit.

If the imaginary point is at the extreme right, then the number is an integer. If the imaginary binary point is at the extreme left for an unsigned number, the number is an unsigned fraction. If the binary point is to the immediate right of the MS bit, the number is a signed fraction. If the binary point is in the middle of a bit sequence, the number has an integer and a fractional part.

Let us discuss on 2’s complement fractions. As an example, the value of 1 001, if the interpretation is that it is a 2's complement fraction will be as follows - It is 1.001 assuming the binary point after the MS bit. As the MS bit is 1, it is a negative number. Then the remaining bits do not specify the magnitude directly. The 2's complement of 1 001 is 0110+ 1 = 0 111. This is a positive fraction with the value 1 × 2−1 +1 × 2−2 +1 × 2−3 =0.5 + 0.25 + 0.125 = 0.875 decimal. Thus, -0.875 is the value of 1001.

If the word size is n bits, the smallest magnitude non-zero fraction that can be represented is 2(n-1). A table of word size and the smallest magnitude fraction that can be represented as shown in the following.

Word size
Smallest magnitude 2 's complement fraction
±0.5 × 10-9

The minimum word size has to be 8 bits to represent the number -0.0123 somewhat accurately. The accuracy is very much improved if the word size is further increased.

Updated on 27-Jun-2020 13:11:24