Binary Number System

Binary Number System

Published by: Nuru

Published date: 22 Jun 2021

Binary Number System Photo

Binary Number System

Binary Number System is a base-2 number system, which only uses two digits (0 & 1). It is a system used at the heart of every digital computer, allowing them to encode information, perform arithmetic operations and execute logical control processes.

Using two digits as opposed to, say, the familiar ten digits used in decimal systems (0 to 9) enables the hardware to be easily implemented via simple ‘on’ or ‘off’ circuit states or logic gates. This is the basis for all digital systems.

To understand binary values imagine each digit (or ‘bit’) of the binary notation as representing an increasing power of 2 - with the rightmost digit representing 20, the next representing 21, then 22, and so on.

For each bit, the 1 or 0 signifies whether the value of the increasing power of two summates towards the number's total. Binary values are often represented in different ‘bit’ lengths or ‘word’ sizes. In the example above the value is represented in 4-bits, called a ‘nibble’. This means a value between 0 and 15 can be represented. 8-bit values referred to as ‘bytes’ can represent a value between 0 and 255. Figure 3 shows the 4-bit binary representation for each decimal value between 0 and 15.

- Example: Binary Number = 1101.1
= 1 * 23 + 1 * 22 + 0 * 21 +1 * 20 +1*2-1
= 8+4+0+1+0.5 = 13.5 (Decimal No.)

1’s and 2’s complement of a Binary Number

Given a Binary Number as a string, print its 1’s and 2’s complements.

1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0.

Example: 1's complement of 0111 is 1000.

1's complement of 1100 is 0011.

2’s complement of a binary number is 1 added to the 1’s complement of the binary number.

Example: 2's complement of 0111 is 1001.

2's complement of 1100 is 0100.