DEV Community

Cover image for Binary: How Computers Count
Alex Hebert
Alex Hebert

Posted on

Binary: How Computers Count

Many people are familiar with the trope of a tunnel of green 0s and 1s zooming by as a movie character hacks the mainframe or enters the computer world, but few know the signifigance these 0s and 1s have to comuting. Most modern programming languages have abstracted away the need for directly interacting with the binary foundation they rely on, so many programmers are left without an understanding of how the binary number system works or its importance to computing.

What is Binary

Simply, binary is counting with base 2. The counting system we are familiar with is base 10. A counting systems base can be thought of as the number you count to before moving to the next position. For example, in base 10, counting from 0 to 9 only uses a single position but counting from 10 to 99 uses two. The term base comes from the fact each position of the number is representative of an amount of the base raised to a power. In base 10 the ones place is representative of 10^0, the tens place is 10^1, the hundreds is 10^2 and so on. This allows us to construct numbers to represent a certian combination of the base 10 exponents based on the position of the digit. So 143 is 1*10^2 + 4*10^1 + 3*10^0 or 100 + 40 + 3.
Image description
This carries over to binary but instead of using 10 as the base, we use 2. So the first place is 2^0, then 2^1, 2^2, and so on. This is where the zeros and ones come in. Since in binary you only count to 1 before moving to the next place the only digits seen in binary counting are 0 and 1. In binary 143 would be 1*2^7 0*2^6 0*2^5 0*2^4 1*2^3 1*2^2 1*2^1 1*2^0 or 128 + 8 + 4 + 2 + 1 or 10001111.

Why is binary imprortant?

Computing is all about logic and binary provides a great representation of the simplest unit of logic, true and false. Since there can be no in between with true and false, binary is the perfect fit since it only uses two numbers. Before digital computers were even considered a possiblity, 1854, George Boole published a paper utilizing binary to formalize what is known as Boolean Algebra. Boolean Algebra would later become the cornerstone to digital computing, providing an avenue for completing ariethmetic and logical calculations with digital circuts. These are still the foundations of modern computing, all made possible thanks to binary.

Further Reading:
Wikipedia article detailing the binary number system

Top comments (0)