35.9k views
5 votes
Write down the bit pattern in the fraction of value 1/3 assuming a floating point format that uses Binary Coded Decimal (base 10) numbers in the fraction instead of base 2. Assume there are 24 bits, and you do not need to normalize. Is this representation exact?

1 Answer

4 votes

Answer:

The resulting floating bit representation is:

0 00101010101010101 000001 (24 bits)

Step-by-step explanation:

Converting 1/3 in decimal: 0.3333...

For converting decimal number into binary we know that the digits on the left of decimal are multiplied with positive powers of 2 (starting from zero) while digit on right side are multiplied with negative powers of 2 (starting from -1).

For example: The number 123.45 (decimal) is equal to:

=1 * 10^2 + 2 * 10^1 + 3 * 10^0 + 4 * 10^-1 + 5 * 10^-2

=1 * 100 + 2 * 10 + 3 * 1 + 4 * 0.1 + 5 * 0.01

Now for the decimal number 0.3333... the pattern becomes:

0*0 . 3*2^-1+3^-2+3^-3+3^-4.....

The first negative power (2^-1 = 0.5) is too large to fit. The next one is 2^-2 = 0.25 and it fits, so let's subtract that: 0.3333… - 0.25 = 0.08333… The next power that fits is 2^-4 = 0.0625. Subtracting that from the remaining result we get 0.08333…- 0.0625 = 0.0208333…

Continuing on this line we get:

0.3333333…. (decimal) = 0.0101010101010101….. (binary)

Now for creating a 24 bit floating point format that uses Binary Coded Decimal we have to assign bits as follows:

  • 6 bits for the exponent
  • 17 bits for the mantissa.
  • In this case the sign bit is 0 (1 bit) because the number is non-negative.

As we need not to normalize obtained number, then the exponent will be simply 1, and the mantissa remains: 00101010101010101...

Now

The mantissa is 0.0101010101010101 (17 bits)

The exponent is 000001 (6 bits).

The resulting floating bit representation is 0 00101010101010101 000001

User Chrysa
by
7.4k points