DEV Community

harshraj8843 for ilihub

Posted on • Originally published at ilihub.tech

What is a Binary Number?

A binary number is a number expressed in the base-2 numeral system, which uses only two digits: 0 and 1. This is in contrast to the decimal (base-10) numeral system that we use in everyday life, which uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

In the binary system, each digit represents a power of 2, starting with 202^0 (which is equal to 1) and increasing by a factor of 2 for each successive digit. For example, the binary number 1011 represents:

1×23+0×22+1×21+1×20=8+0+2+1=11 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 8 + 0 + 2 + 1 = 11

Binary numbers are commonly used in computer science and digital electronics because they can be easily represented using electronic switches that are either on or off (i.e., 1 or 0). This makes them ideal for representing digital data, such as the instructions that a computer executes or the pixels in a digital image.

In addition to binary, there are other numeral systems that use different bases, such as octal (base-8) and hexadecimal (base-16). These systems are also commonly used in computer science and digital electronics because they can be easily converted to and from binary.

Examples

The following table shows the decimal, binary representations of the numbers 0 through 15:

Decimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111

References


Top comments (2)

Collapse
 
devarshishimpi profile image
Devarshi Shimpi

Thanks for sharing!

Collapse
 
arindam_1729 profile image
Arindam Majumder

Great Share