Search⌘ K
AI Features

Binary Number System and Its Representation

Explore the binary number system, its role in computing, and the methods to convert between binary and decimal values. Understand how binary represents electrical signals in computers and learn the fundamentals of binary counting and ASCII representation.

What is the binary number system?

Another number system that became famous after the decimal is the binary number system, which has only two digits, 0 and 1.

If a number system has n digits, we say that the base of the number system is n. So the binary number system can also be called the base-2 number system.

Why does a computer understand binary?

The simplest explanation would be that a computer is an electrical device, and all electrical devices understand electrical signals, which have only two states.

For example:

If we have an input wire to this machine, there are only two possible states for this wire: either the current is flowing through this wire, or it is not flowing through this wire. If the current is flowing, we say that the state of this wire is signaled. And we say that the signal state corresponds to 1.

If the current is not flowing, it is not signaled. The not signal state corresponds to 0. So, 1 and 0, in binary, translate to a signal or non-signal in an electrical device, and we can have multiple wires or multiple inputs to represent multiple ones and zeros.

Powers of 2

Power of two Binary Decimal value
202^{0} 0001 1
212^{1} 0010 2
222^{2} 0100 4
232^{3} 1000 8
242^{4} 0001 0000 16
252^{5} 0010 0000 32
262^{6} 0100 0000 64
272^{7} 1000 0000 128
282^{8} 0001 0000 0000 256
292^{9} 0010 0000 0000 512
2102^{10} 0100 0000 0000 1,024

As we see, the powers of 2 are increasing, so the bits go from right to left based on the decimal value given as input. All other left bits will be 0.

For example:

125 can be represented as 01111101 in the computer binary system. Anything in computer language gets converted into a binary number system.

What do binary numbers represent?

In mathematics and digital electronics:

  • A binary number is a number expressed in the base-2 number system or binary number system.
  • It uses only two symbols: typically “0” (zero) and “1” (one).

The base-2 number system is a positional notation with a radix of 2. Each digit is referred to as a bit.

Binary counting

Binary counting follows the same procedure, except that only the two symbols 0 and 1 are available. Thus, after a digit reaches 1 in binary, an increment resets it to 0 but also causes an increment of the next digit to the left.

0000,

0001, (rightmost digit starts over, and next digit is incremented)

0010, 0011, (rightmost two digits start over, and next digit is incremented)

0100, 0101, 0110, 0111, (rightmost three digits start over, and the next digit is incremented)

1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111,…

Binary to decimal conversion

In the binary system, each digit represents an increasing power of 2, with the rightmost digit representing 202^{0}, the next representing 212^{1}, then 222^{2}, and so on. The value of a binary number is the sum of the powers of 2 represented by each “1” digit. For example, the binary number 100101 is converted to decimal form as follows:

1001012100101_{2} = [ ( 1 ) × 252^{5} ] + [ ( 0 ) × 242^{4} ] + [ ( 0 ) × 232^{3} ] + [ ( 1 ) × 222^{2} ] + [ ( 0 ) × 212^{1} ] + [ ( 1 ) × 202^{0}]

1001012100101_{2} = [ ( 1 ) × 32 ] + [ ( 0 ) × 16 ] + [ ( 0 ) × 8 ] + [ ( 1 ) × 4 ] + [ ( 0 ) × 2 ] + [ ( 1 ) × 1]

1001012100101_{2} = 371037_{10}


Below is a widget that shows output of these concepts in HTML. In the next lessons, we will cover output more in-depth.

Decimal to binary representation

Below is the 32-bit binary representation.

5 -> 00000000 00000000 00000000 00000101

Below is another widget that shows output in HTML. In the next lessons, we will cover this topic in-depth.


Representing decimals & ASCII in binary

A computer only understands byte-code that is made of 0’s and 1’s. We have to represent every decimal character as binary digits so a computer can understand the instructions we give.

Decimal numbers in binary (8-bit representation)

Each software programming language uses its own pre-defined sizes for primitive data types. So, let’s represent the rightmost 8-bits (1 byte) in binary.

Decimal number 8-bit binary representation
0 0000 0000
1 0000 0001
2 0000 0010
3 0000 0011
4 0000 0100
5 0000 0101
6 0000 0110
7 0000 0111
8 0000 1000
9 0000 1001
10 0000 1010

ASCII - Binary character table

Alphabets in binary (capital letters & lowercase letters)

Letter ASCII Code Binary Letter ASCII Code Binary
a 097 01100001 A 065 01000001
b 098 01100010 B 066 01000010
c 099 01100011 C 067 01000011
d 100 01100100 D 068 01000100
e 101 01100101 E 069 01000101
f 102 01100110 F 070 01000110
g 103 01100111 G 071 01000111
h 104 01101000 H 072 01001000
i 105 01101001 I 073 01001001
j 106 01101010 J 074 01001010
k 107 01101011 K 075 01001011
l 108 01101100 L 076 01001100
m 109 01101101 M 077 01001101
n 110 01101110 N 078 01001110
o 111 01101111 O 079 01001111
p 112 01110000 P 080 01010000
q 113 01110001 Q 081 01010001
r 114 01110010 R 082 01010010
s 115 01110011 S 083 01010011
t 116 01110100 T 084 01010100
u 117 01110101 U 085 01010101
v 118 01110110 V 086 01010110
w 119 01110111 W 087 01010111
x 120 01111000 X 088 01011000
y 121 01111001 Y 089 01011001
z 122 01111010 Z 090 01011010