Javatpoint Logo
Javatpoint Logo

What is Binary?

Gottfried Leibniz invented the binary number, which is a base-2 number system and consists of only two numbers or digits: 0 (zero) and 1 (one). This numerical system serves as the foundation for all binary code, which is utilized in order to write digital data like computer processor instructions utilized every day.

Any digital encoding/decoding system with exactly two potential states is also referred to as a binary encoding/decoding system. Sometimes, the 0 and 1 numbers are commonly referred to as "low" and "high," respectively, in digital data memory, processing, storage, and communications.

On the computer, the smallest unit of data is a bit (short for binary digit); every bit contains a single value of 1 or 0. Binary files with the extension ".bin" are commonly used to identify executable (ready-to-run) programs. Binary is a term that is also used by programmers to refer to executable files.

How does binary work?

In binary, the 0s and 1s signify OFF and ON, respectively. A "0" in a transistor indicates that no electricity is flowing, while a "1" indicates that electricity is flowing. Numbers are physically represented inside the computing equipment in this fashion, which allow calculations. In this page, below, we go over this concept in further detail in the section on how to read binary numbers.

Why do computers use binary?

Binary remains the principal computer language for the following reasons, and it is still used in electronics and computer hardware.

  • It is an attractive and straightforward design.
  • If an electrical signal is off (false) or on (true), the binary 0 and 1 approach is fast for detecting.
  • Electrical signals with only two states located widely apart are less sensitive to electrical interference.
  • Magnetic media's positive and negative poles are immediately converted to binary.
  • The most effective approach to regulate logic circuits is via binary.

How to read binary numbers

The binary number 01010101 is depicted in the given diagram below. As you walk through the eight positions, each column symbolizes the number two increased to an exponent, with the value of that exponent increasing by one. You are required to go through the chart from right side to left side and add the values of each column in order to the previous column to obtain the sum of this instance: (1+4+16+64) = 85. We don't count the bits with a zero (0) because they are "shut/turned off," as you can see.

Exponent 27 26 25 24 23 22 21 20
Value 128 64 32 16 8 4 2 1
ON/OFF 0 1 0 1 0 1 0 1

The next example is the binary value 01101000 given below, which is the maximum 8-bit value of 104. Again, start reading right to the left we have 8+32+64 = 104.

Value 128 64 32 16 8 4 2 1
ON/OFF 0 1 1 0 1 0 0 0

Another example is the binary value 11111111, which is the maximum 8-bit value of 255. When you start reading right to the left, you will have 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255.

Value 128 64 32 16 8 4 2 1
ON/OFF 1 1 1 1 1 1 1 1

Note: Commonly, counting on a computer begins with "0" rather than "1." As a result, counting all the bits equals 255, yet starting at 0 equal 256.

A byte is defined as eight bits divided by the number of bits in the byte. When you translate the binary code from the previous example (01101000), which totalled "104," into ASCII, you will obtain a lowercase "h." To spell the word "hi," you will need to include the binary for the letter I which is 01101001." With the help of combining these two codes, we get 0110100001101001 or 104 and 105, which stands for "hi."

How to add in binary

Adding binary numbers is much like to adding decimal numbers. For example, if we had the binary 01101011 (107) and wanted to add 10000111 (135), we'd do it like this:

+ 0 1 1 0 1 0 1 1
1 0 0 0 0 1 1 1

We will start on the right side and add 1+1 to obtain "2." Because there is no number two in binary, we would use the binary value "10" and carry the "1" to the next column.


Now we will add the "1" from the previous column to the "3" in the next column. And, because there is no number "3" in binary, we use "11," which represents 3 in binary, and write 1 and carry the 1 to the next column.

1 0

Then, we would take the "1," which was carried over, and add it by 1+0+1 in order to get "10," which demonstrates 2 in binary.

0 1 0

To arrive at the result 11110010. (242), we repeat this same process for all eight digits.

1 1 1 1 0 0 1 0

What are a left shift and right shift?

The act of shifting (moving) each bit of a binary number to the left is known as a left shift, and it is used to double the binary value or multiply by two. For example, the binary number "00111110," which equals 62 when the bits are shifted to the left, becomes "01111100," or 124, when the bits are moved to the right. Another example is when the binary number "00000011" equals three and is left-shifted to "00000110," which equals six.

A right shift is identical to a left shift, except that to divide a number by two, the bits are moved to the right. When a right shift operation is performed, the binary number "00001010" equals ten and becomes "00000101" or five.

What is the "0b" prefix?

In order to help avoid misinterpretation, binary number may have a "0b" (zero and b) prefix at the time of writing it. For instance, in binary, 0b0100 stands for "0100." The reader can tell this is not "100" in decimal form because of the prefix.

Binary humor

The below picture is an instance of some binary comedy (joke) via a popular saying on many geek t-shirts. "There are only two types of people in the world: those who understand binary and those who don't," this quote truly speaks to those who can read binary. Ten is two in the binary system, not ten.

What is Binary

The term binary may also refer to the following:

  • Binary is a command that changes the file transfer mode to binary while in an FTP session.
  • The term "binary" can also refer to an executable file when used as a noun. For case, "Find the binary labelled program.exe and double-click it."

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA