DEV Community

Lilit Hovanes
Lilit Hovanes

Posted on

Binary numbers, conversions between different number representations - Lilit Hovanes

There exists an imaginary world, where everything is reduced to two simple options: on and off, yes or no, 1 or 0. But believe it or not, this isn't just imaginary, computers understand this secret language called binary system. At its core, binary is a base-2 number system, utilizing only two symbols: 0 and 1, which is fundamental in computing because it aligns perfectly with the on-and-off states of electronic circuits. This simplicity is powerful. In binary, each position represents a power of 2, just like in decimal each position represents a power of 10. Understanding how to switch between different number representations can feel like learning to speak new languages. Converting binary to decimal involves summing powers of 2. For example the binary number 1011: if we number it from right to left we will get 1*2^0 + 1*2^1 + 0*2^2 + 1*2^3 = 1+2+0+8 = 11 in decimal number system. To convert a decimal number into binary, we have to repeatedly divide by 2 and keep track of the remainders. In the case of 26, we get
26 ÷ 2 = 13, remainder 0
13 ÷ 2 = 6, remainder 1
6 ÷ 2 = 3, remainder 0
3 ÷ 2 = 1, remainder 1
1 ÷ 2 = 0, remainder 1
Now, if we read the remainders from bottom to top we get the number 11010 in binary.
Converting binary to hexadecimal is like bundling bits into neat packages of four. For example, the binary 10111011 can be grouped as 1011 (B in hex) and 1011 (B in hex). Thus, 10111011 in binary becomes BB in hexadecimal.
But why is it important to understand conversions? Understanding these number systems is essential for computer science, programming, and digital electronics. Every time we use our smartphones or browse the internet, binary is working its magic behind the scenes!
As we advance in the age of technology, binary numbers will stay central to innovation. At the core of every computer is its brain, the CPU (Central Processing Unit). It's fun to look at it as if a conductor leading an orchestra, where each note represents a binary digit. Without this system, our devices wouldn't be able to function or communicate. Every email we send and every video we stream undergoes a fascinating transformation into tiny pieces of binary code. When we hit "send" on an email, the message is divided into small packets of data, each represented by sequences of 0s and 1s. This allows your computer to efficiently transmit the information over the internet. When we listen to a song or watch a film, the audio and visual elements are also represented in binary form. Nowadays, binary is a key player in emerging fields like artificial intelligence and machine learning.

Top comments (0)