Share |

Number Systems

The 0s and 1s present in the logic circuits discussed in the course can be used to represent real data inside logic circuitry in, for example, microprocessors. To do this a binary format has to be adopted.

The usual practise is to use so-called pure binary coding whereby each binary digit (either 0 or 1) carries a certain weight according to its position in the binary number. So, for example

110100=1x25+ 1x24+0x23 +1x22+0x21 +0x20
=32+16+ 0+4+0+ 0
=52

 

The same approach applies to non-integral numbers so, for example

110.101=1x22+ 1x21+0x20 +1x2-1+0x2-2 +1x2-3
=4+2+ 0+0.5+0+ 0.125
=6.625

 

These examples illustrate binary to decimal conversion. To convert a fractional decimal number to binary then the procedure to follow is

  • first divide the number at the decimal point and treat the two parts separately.
  • For the integer part then repeatedly divide it by 2 and store the remainder until nothing is left.
  • The remainders when reverse-ordered gives the first part of the binary number. The reverse-ordering comes about since the first division by 2 gives the least significant bit (lsb) and so on until the last division which gives the most significant bit (msb).
  • For the fractional part repeatedly multiply by 2 and record the carries i.e. when the resulting number is greater than 1. Repeat this process until the desired precision is achieved.
An full example of this technique is given in the Solved Problems.

 

A useful way of expressing long pure binary coded numbers is by the use of hexadecimal numbers i.e. base 16. This is because each group of four bits (called a nibble since 2 nibbles make a byte!) can be converted into one hexadecimal number. The mapping between binary, decimal and hexadecimal (hex.) numbers is shown below.

DecimalBinaryHexDecimalBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F

 

To convert a binary number into its hexadecimal equivalent first ensure that the binary number has a number of digits that is a multiple of 4, if not add zeros to the left hand side of the number until it does. Then split the number into nibbles and convert each nibble into its hexadecimal counterpart.

An example of binary to hexadecimal conversion can be found in the Solved Problems.