Binary codes are used to represent the distinct discrete element of information. They are patterns of 1s and 0s for a computer to understand information other than binary numbers.

The discrete elements of information are not only binary numbers but also, other types of information such as decimal numbers, etc.

## Binary Code

Suppose we have an n-bit code then there are 2^{n} combination of binary codes consists of 1s and 0s.

For example,

3-bit code has 2^{3} = 8 codes

Bit Combination | Codes |
---|---|

0 | 000 |

1 | 001 |

2 | 010 |

3 | 011 |

4 | 100 |

5 | 101 |

6 | 110 |

7 | 111 |

There are 8 combinations, but the bit combination has value is between 0 to 2^{n} – 1. A 3-bit code has bit combination from 0 to 2^{3} – 1 = 7.

## Minimum bits required

For 16 code combinations, you need minimum of 4 bits, n = 4 bits, so that 2^{4 }= 16.

For 8 codes, you need a minimum of 3 bits like in the example above,

n = 3 bits so that 2^{3 }= 8.

## Maximum bit for Binary Code

There is no restriction on a number of bits that you can use for a binary code.

For example

10 decimal numbers – 0,1,2,3,4,5,6,7,8,9 can be represented using 4-bits and can also be represented using 10-bits. Let’s check this for first 5 decimal numbers.

Decimal value | 4-bit code | 10-bit code |
---|---|---|

0 | 0000 | 0000000000 |

1 | 0001 | 0000000010 |

2 | 0010 | 0000000100 |

3 | 0011 | 0000001000 |

4 | 0100 | 0000010000 |

A 4-bit code is binary representation of decimal and 10-bit code uses placeholder for each decimal number. Here the code – 0000010000 does not mean 2^{5} = 16, but it means 5^{th} position from right is a 1, therefore, decimal number = 4.

## Bibliography

John.F.Wakerly. 2008. *Digital Design: Principles And Practices, 4/E.* Pearson Education, India.

Mano, M. Morris. 1984. *Digital Design.* Pearson.

NATARAJAN, ANANDA. 2015. *Digital Design.* PHI Learning Pvt. Ltd.