DEV Community

Tim Udoma
Tim Udoma

Posted on

Beneath the Rug, Computer Processing

You have probably heard that the CPU processing is done in 0s and 1s. Have you ever wondered how this is possible?

Consider the number 11. This number is represented as eleven in the decimal numbering system. The decimal system is a representation of numbers using digits 0 – 9. The number 11 simply means the second number after the roundtrip from 0 – 9. The same number represented in the binary system is 1011. Note that the number of digits used for representing the same number is reduced (11 vs 1011), this is an attribute known as compactness. Since computers are better at handling numbers, using the binary system ensures accuracy and precision at the expense of compactness. These binary numbers are usually represented in 8-digit bit strings called bytes. For example, the representation of the number 1011 would be 00001011, with extra zeros used for padding.

At this point, you are probably wondering, what about the text on my screen? The CPU uses a text conversion process called character encoding to translate text to numbers. Think of it as a dictionary. Every character is a key, tied to a numeric value. Assuming A has a value of 1 in the dictionary, B would have the value of 2. This dictionary is case sensitive; hence the alphabet A has a different value from the alphabet a. Initially, computers used ASCII, a character encoding scheme modeled for only English characters, today computers use Unicode which encompasses 100, 000 characters (including your favorite emoji 😀).

Images follow a similar but slightly more complex pattern. At the smallest level, every image is made up of a pixel. On a color screen, every pixel is represented using three colors Red, Green, and Blue (RGB). Each color uses an 8-bit number to represent the color intensity. For example, 255 255 255 means all three colors are at the highest intensity for the particular pixel, and 000 000 000 means all colors are set to the lowest intensity. Interestingly, since images can be described in terms of numbers, mathematical calculations can be done on images. This is the basis of facial and character recognition systems using machine learning.

If you learned something new from this article, please like and share

Top comments (0)