DEV Community

Jidneya
Jidneya

Posted on

Math in computer science: Binary

Binary is fundamental in the study of computer science and is the basis for all digital computing. It is the system that computer use to represent data in which each digit can only have one of two possible digits: 1 or 0.

One reason that computers use binary is because of the fact that transistors are used in commuter processors, and these can have two states, ON or OFF. So the 1 in binary is for ON and the 0 is for OFF, but what does binary actually represent and how do 1 and 0's become what we see on our screens.

How binary works

A binary number is a series of 8 binary digits (bits), and these are called bytes. These are what are used for the computer to process and hold data. In a byte the bit position is the power of 2 that that position represents. This means that the 5th bit will represent either a decimal value of0 if the binary is 0, or a decimal value of 2^5 if the binary value is 1. Like this you can represent 256 numbers from just one byte.

Image description

What makes binary different to decimal

Binary is a Base-2 system, meaning that each bit can only take two values. On the other hand the decimal system, which is the one we use in daily life uses a base-10 system, so each digit can take 10 different values, ranging from 0 to 9.

How is binary used

Different decimal numbers are used to represent different things in our computers, such as numbers, letters and even color's. So for example the ASCII decimal value for the letter "A" is 65, and so when we type "A", we actually give the processor the byte 01000001, and it then converts this into the letter "A", and we see it on our screen. This is the same for numbers and color's.

I hope you now see how fundamental binary is and how is allows our computers to display and store multitudes of data.

Top comments (0)