✅ Binary Formula ⭐️⭐️⭐️⭐️⭐

5/5 - (1 bình chọn)

The Binary Numbering System is the most fundamental numbering system in mathematics as well as in all digital and computer-based systems. Binary numbers follow the same set of rules as the decimal numbering system.

The Binary Numbering System contains only 0’s and 1’s. A binary number such as 101100101 is expressed with a string of 0’s and 1’s with each digit having a value twice that of the previous digit.

While, writing the binary numbers you need to signify the number is binary (base 2), for instance: let’s take the value 101. As it is written, it would be hard to know to work out whether it is a binary or decimal value.

The weight of each binary bit relies on its relative position within the number. The binary formula to convert decimal to binary is given below:

Binary to Decimal Formula

DecimalNumber=nthbit×2n−1

To convert binary to decimal the following chart is used and binary is noted as per the given decimal number.

Converting binary to a decimal number or decimal to binary number is an easy task. But, you need to be careful not to mix up the two sets of numbers. For instance, if you write the digits 10 on the page it could mean the number “ten” if we assume it to be a decimal number, or it could equally be a “1” and a “0” together in binary, which is equal to the number two in the weighted decimal format from above table.

So, for instance, if you use a binary number string it should add the subscript “2” to denote a base 2 number so the binary number would be written as 102.

Likewise, if it was a standard decimal number it would add the subscript “10” to denote a base 10 and written as 1010.

Binary Numbers Addition basic rules

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0(CARRY 1)

1 + 1 + 1 = 11(CARRY 1)

Binary Numbers Subtraction

0 – 0 = 0

0 – 1 = 1 (with a borrow of 1 )

1 – 0 = 1

1 – 1 = 0

Binary Examples

Here are some examples of adding and subtracting binary numbers.

Example 1: Add the following binary numbers:

111002 and 101102.

Solution:

Given binary numbers are: 11100 and 10110

11100 +

10110

———–

110010

———–

Example 2: Subtract (10001)2 from (11101)2

Solution:

Given digits are 11101 and 10001

11101

-10001

———-

01100

———-

Binary numbers – Conversion formulas and mathematical operations

In this section we will explain what binary is and show you how to convert between binary and decimal (denary) numbers.

We will also show you how to perform various mathematical operations on binary numbers, including multiplication and division.

Binary Numbers Overview

Binary is a number system used by digital devices such as computers, smartphones and tablets. It is also used in digital audio devices such as cd players and MP3 players.

Electronically binary numbers are stored/processed using off or on electrical pulses, a digital system will interpret these off and on states as 0 and 1. In other words if the voltage is low then it would represent 0 (off state), and if the voltage is high then it would represent a 1 (on state).

Binary is Base 2, unlike our counting system decimal which is Base 10 (denary).

In other words, Binary has only 2 different numerals (0 and 1) to denote a value, unlike Decimal which has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).

Here is an example of a binary number: 10011100

As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make this an 8 bit binary number. Bit is short for Binary Digit, and each numeral is classed as a bit.

The bit on the far right, in this case a 0, is known as the Least significant bit (LSB).

The bit on the far left, in this case a 1, is known as the Most significant bit (MSB)

notations used in digital systems:
4 bits = Nibble
8 bits = Byte
16 bits = Word
32 bits = Double word
64 bits = Quad Word (or paragraph)

When writing binary numbers you will need to signify that the number is binary (base 2), as an example let’s take the value 101. As it is written, it would be hard to work out whether it is a binary or decimal (denary) value. To get around this problem it is common to denote the base to which the number belongs by writing the base value with the number, for example:

1012 is a binary number and 10110 is a decimal (denary) value.

Once we know the base then it is easy to work out the value, for example:

1012 = 1*22 + 0*21 + 1*20 = 5 (five)

10110 = 1*102 + 0*101 + 1*100 = 101 (one hundred and one)

One other thing about binary numbers is that it is common to signify a negative binary value by placing a 1 (one) at the left hand side (most significant bit) of the value. This is called a sign bit, we will discuss this in more detail below.

Converting binary to decimal

To convert binary into decimal is very simple and can be done as shown below:

Say we want to convert the 8 bit value 10011101 into a decimal value, we can use a formula table like that below:

1286432168421
10011101

As you can see, we have placed the numbers 1, 2, 4, 8, 16, 32, 64, 128 (powers of two) in reverse numerical order, and then written the binary value below.

To convert, you simply take a value from the top row wherever there is a 1 below and then add the values together.

For instance, in our example we would have 128 + 16 + 8 + 4 + 1 = 157.

For a 16 bit value you would use the decimal values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 (powers of two) for the conversion.

Because we know binary is base 2 then the above could be written as:

1*27 + 0*26 + 0*25 + 1*24 + 1*23 + 1*22 + 0*21 + 1*20 = 157.

Converting decimal to binary

To convert decimal to binary is also very simple, you simply divide the decimal value by 2 and then write down the remainder. Repeat this process until you cannot divide by 2 anymore, for example let’s take the decimal value 157:

157 ÷ 2 = 78
78 ÷ 2 = 39
39 ÷ 2 = 19
19 ÷ 2 = 9
9 ÷ 2 = 4
4 ÷ 2 = 2
2 ÷ 2 = 1
1 ÷ 2 = 0
with a remainder of 1
with a remainder of 0
with a remainder of 1
with a remainder of 1
with a remainder of 1
with a remainder of 0
with a remainder of 0
with a remainder of 1
<— to convert write this remainder first.

Next, write down the value of the remainders from bottom to top (in other words write down the bottom remainder first and work your way up the list) which gives:

10011101 = 157

Adding binary numbers

Adding binary numbers is very similar to adding decimal numbers, first an example:

Let’s look at the above example step by step:

1 + 1 = 0 (carry one)
1 + 1 (+ the carry) = 1 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)

The last carry is placed at the left hand side of the result giving: 10000010

Subtracting binary numbers

The most common way of subtracting binary numbers is done by first taking the second value (the number to be subtracted) and apply what is known as two’s complement, this is done in two steps:

  1. complement each digit in turn (change 1 for 0 and 0 for 1).
  2. add 1 (one) to the result.

note: the first step by itself is known as one’s complement.

By applying these steps you are effectively turning the value into a negative number, and as when dealing with decimal numbers, if you add a negative number to a positive number then you are effectively subtracting to the same value.

In other words 25 + (-8) = 17, which is the same as writing 25 – 8 = 17.

An example, let’s do the following subtraction 11101011 – 01100110 (23510 – 10210)

note: When subtracting binary values it is important to maintain the same amount of digits for each number, even if it means placing zeroes to the left of the value to make up the digits. For instance, in our example we have added a zero to the left of the value 1100110 to make the amount of numerals up to 8 (one byte) 01100110.

First we apply two’s complement to 01100110

which gives us 10011010.

Now we need to add 11101011 + 10011010, however when you do the addition you always disregard the last carry, so our example would be:

which gives us 10000101, now we can convert this value into decimal, which gives 13310

So the full calculation in decimal is 23510 – 10210 = 13310 (correct!)

Negative numbers

The above example is subtracting a smaller number from a larger number.

If you want to subtract a larger number from a smaller number (giving a negative result), then the process is slightly different.

Usually, to indicate a negative number, the most significant bit (left hand bit) is set to 1 and the remaining 7 digits are used to express the value. In this format the MSB is referred to as the sign bit.

Here are the steps for subtracting a large number from a smaller one (negative result).

  1. Apply two’s complement to the larger number.
  2. Add this value to the smaller number.
  3. Change the sign bit (MSB) to zero.
  4. Apply two’s complement to value to get final result.
  5. The most significant bit (sign bit) now indicates the value is negative.

For example let’s do the following subtraction 10010101 – 10110100 (14910 – 18010)

The process is as follows:

Now we can convert this value into a negative decimal, which gives -3110

So, the full calculation in decimal is 14910 – 18010 = -3110 (correct!)

Multiplying binary numbers

Binary multiplication can be achieved in a similar fashion to multiplying decimal values.

Using the long multiplication method, ie, by multiplying each digit in turn and then adding the values together.

For example, lets do the following multiplication: 1011 x 111 (decimal 1110x 710)

which gives us 1001101, now we can convert this value into decimal, which gives 7710

So the full calculation in decimal is 1110x 710 = 7710 (correct !!)

note:Notice the pattern in the partial products, as you can see multiplying a binary value by two can be achieved by shifting the bits to the left and adding zeroes to the right.

Dividing binary numbers

Like multiplication, dividing binary values is the same as long division in decimal.

For example, lets do the following division: 1001 ÷ 11 (decimal 910÷ 310)

which gives us 0011, now we can convert this value into decimal, which gives 310

So the full calculation in decimal is 910÷ 310 = 310 (correct!)

note:Dividing a binary value by two can also be achieved by shifting the bits to the right and adding zeroes to the left.

Binary Calculator

The binary system is a numerical system that functions virtually identically to the decimal number system that people are likely more familiar with. While the decimal number system uses the number 10 as its base, the binary system uses 2. Furthermore, although the decimal system uses the digits 0 through 9, the binary system uses only 0 and 1, and each digit is referred to as a bit. Apart from these differences, operations such as addition, subtraction, multiplication, and division are all computed following the same rules as the decimal system.

Almost all modern technology and computers use the binary system due to its ease of implementation in digital circuitry using logic gates. It is much simpler to design hardware that only needs to detect two states, on and off (or true/false, present/absent, etc.). Using a decimal system would require hardware that can detect 10 states for the digits 0 through 9, and is more complicated.

Below are some typical conversions between binary and decimal values:

Binary/Decimal Conversion

DecimalBinary
00
11
210
311
4100
7111
81000
101010
1610000
2010100

While working with binary may initially seem confusing, understanding that each binary place value represents 2n, just as each decimal place represents 10n, should help clarify. Take the number 8 for example. In the decimal number system, 8 is positioned in the first decimal place left of the decimal point, signifying the 100 place. Essentially this means:

8 × 100 = 8 × 1 = 8

Using the number 18 for comparison:

(1 × 101) + (8 × 100) = 10 + 8 = 18

In binary, 8 is represented as 1000. Reading from right to left, the first 0 represents 20, the second 21, the third 22, and the fourth 23; just like the decimal system, except with a base of 2 rather than 10. Since 23 = 8, a 1 is entered in its position yielding 1000. Using 18, or 10010 as an example:

18 = 16 + 2 = 24 + 21
10010 = (1 × 24) + (0 × 23) + (0 × 22) + (1 × 21) + (0 × 20) = 18

The step by step process to convert from the decimal to the binary system is:

  1. Find the largest power of 2 that lies within the given number
  2. Subtract that value from the given number
  3. Find the largest power of 2 within the remainder found in step 2
  4. Repeat until there is no remainder
  5. Enter a 1 for each binary place value that was found, and a 0 for the rest

Using the target of 18 again as an example, below is another way to visualize this:

2n 24 23 22 21 20
Instances within 18 1 0 0 1 0
Target: 18 18 – 16 = 2 2 – 2 = 0  

Converting from the binary to the decimal system is simpler. Determine all of the place values where 1 occurs, and find the sum of the values.

EX: 10111 = (1 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20) = 23

2423222120
10111
160421

Hence: 16 + 4 + 2 + 1 = 23.

Binary Addition

Binary addition follows the same rules as addition in the decimal system except that rather than carrying a 1 over when the values added equal 10, carry over occurs when the result of addition equals 2. Refer to the example below for clarification.

Note that in the binary system:

EX:

The only real difference between binary and decimal addition is that the value 2 in the binary system is the equivalent of 10 in the decimal system. Note that the superscripted 1’s represent digits that are carried over. A common mistake to watch out for when conducting binary addition is in the case where 1 + 1 = 0 also has a 1 carried over from the previous column to its right. The value at the bottom should then be 1 from the carried over 1 rather than 0. This can be observed in the third column from the right in the above example.

Binary Subtraction

Similar to binary addition, there is little difference between binary and decimal subtraction except those that arise from using only the digits 0 and 1. Borrowing occurs in any instance where the number that is subtracted is larger than the number it is being subtracted from. In binary subtraction, the only case where borrowing is necessary is when 1 is subtracted from 0. When this occurs, the 0 in the borrowing column essentially becomes “2” (changing the 0-1 into 2-1 = 1) while reducing the 1 in the column being borrowed from by 1. If the following column is also 0, borrowing will have to occur from each subsequent column until a column with a value of 1 can be reduced to 0. Refer to the example below for clarification.

Note that in the binary system:

Note that the superscripts displayed are the changes that occur to each bit when borrowing. The borrowing column essentially obtains 2 from borrowing, and the column that is borrowed from is reduced by 1.

Binary Multiplication

Binary multiplication is arguably simpler than its decimal counterpart. Since the only values used are 0 and 1, the results that must be added are either the same as the first term, or 0. Note that in each subsequent row, placeholder 0’s need to be added, and the value shifted to the left, just like in decimal multiplication. The complexity in binary multiplication arises from tedious binary addition dependent on how many bits are in each term. Refer to the example below for clarification.

Note that in the binary system:

As can be seen in the example above, the process of binary multiplication is the same as it is in decimal multiplication. Note that the 0 placeholder is written in the second line. Typically the 0 placeholder is not visually present in decimal multiplication. While the same can be done in this example (with the 0 placeholder being assumed rather than explicit), it is included in this example because the 0 is relevant for any binary addition / subtraction calculator, like the one provided on this page. Without the 0 being shown, it would be possible to make the mistake of excluding the 0 when adding the binary values displayed above. Note again that in the binary system, any 0 to the right of a 1 is relevant, while any 0 to the left of the last 1 in the value is not.

EX:

Binary Division

The process of binary division is similar to long division in the decimal system. The dividend is still divided by the divisor in the same manner, with the only significant difference being the use of binary rather than decimal subtraction. Note that a good understanding of binary subtraction is important for conducting binary division. Refer to the example below, as well as to the binary subtraction section for clarification.

Decimal to Binary Formula

The decimal to the binary formula is used to convert decimal numbers to binary numbers. Decimal numbers can be easily converted into binary numbers by using the remainder formula. In the method, we divide the given decimal number recursively by 2 and note down the remainders until we get 0 or 1 as the quotient. We will learn more about the decimal to the binary formula along with a few solved examples in the following section.

What is Decimal to Binary Formula?

In the formula to convert decimal to the binary method, we will perform division on the given decimal number recursively by 2 and note down the remainders till we have either 0 or 1 as the final quotient. Steps that are used to convert decimal to the binary number using decimal to the binary formula are shown below,

Step 1: Divide the given decimal number by 2, note down the remainder.
Step 2: Now divide the quotient thus obtained in the above step by 2, note down the remainder.
Step 3: Repeat the above steps until we get 0 or 1 as a quotient.
Step 4: Write down the last quotient in line with remainders from last to the first, this is our binary conversion of the given decimal number.

Let us have a look at a few solved examples to understand decimal to the binary formula better.

Solved Examples on Decimal to Binary Formula

Example 1: Using decimal to binary formula, convert 29 decimal into a binary number.

Solution:

Using decimal to binary formula, we have,
Step 1: Divide the number by 2, note down the remainder:
29 ÷ 2 gives Q1 = 14, R = 1
Step 2: Divide Q1 by 2, note down the remainder:
14 ÷ 2 gives Q2 = 7, R = 0
Step 3: Divide Q2 by 2, note down the remainder:
7 ÷ 2 gives Q3 = 3, R = 1
Step 4: Divide Q3 by 2, note down the remainder:
3 ÷ 2 gives Q4 = 1, R = 1
Step 5: Write down the last quotient in line with remainders from last to the first, this is our binary conversion of the given decimal number:
11101

Answer: Hence, 29 as binary is 111012.

Example 2: Convert 145 decimal into a binary number.

Solution: 

Using decimal to binary formula, we have,
Step 1: Divide the number by 2, note down the remainder:
145÷ 2 gives Q1 = 72, R = 1
Step 2: Divide Q1 by 2, note down the remainder:
72 ÷ 2 gives Q2 = 36, R = 0
Step 3: Divide Q2 by 2, note down the remainder:
36 ÷ 2 gives Q2 = 18, R = 0
Step 4: Divide Q2 by 2, note down the remainder:
18 ÷ 2 gives Q3 = 9, R = 0
Step 5: Divide Q3 by 2, note down the remainder:
9 ÷ 2 gives Q4 = 4, R = 1
Step 6: Divide Q4 by 2, note down the remainder:
4 ÷ 2 gives Q5 = 2, R = 0
Step 7: Divide Q5 by 2, note down the remainder:
2 ÷ 2 gives Q6 = 1, R = 0
Step 8: Write down the last quotient in line with remainders from last to the first, this is our binary conversion of the given decimal number:
10010001

Answer: Hence, 145 decimal as binary is 100100012

Binary to Decimal Conversion

Binary to Decimal Conversion of numbers uses weighted columns to identify the order of the digits to determine the final value of the number

Conversion of binary to decimal (base-2 to base-10) numbers and back is an important concept to understand as the binary numbering system forms the basis for all computer and digital systems.

The decimal or “denary” counting system uses the Base-of-10 numbering system where each digit in a number takes on one of ten possible values, called “digits”, from 0 to 9, eg. 21310 (Two Hundred and Thirteen).

But as well as having 10 digits ( 0 through 9 ), the decimal numbering system also has the operations of addition ( + ), subtraction ( – ), multiplication ( × ) and division ( ÷ ).

In a decimal system each digit has a value ten times greater than its previous number and this decimal numbering system uses a set of symbols, b, together with a base, q, to determine the weight of each digit within a number. For example, the six in sixty has a lower weighting than the six in six hundred. Then in a binary numbering system we need some way of converting Decimal to Binary as well as back from Binary to Decimal.

Any numbering system can be summarised by the following relationship:

The Decimal Numbering System

In the decimal, base-10 (den) or denary numbering system, each integer number column has values of units, tens, hundreds, thousands, etc as we move along the number from right to left. Mathematically these values are written as 100, 101, 102, 103 etc. Then each position to the left of the decimal point indicates an increased positive power of 10. Likewise, for fractional numbers the weight of the number becomes more negative as we move from left to right, 10-1, 10-2, 10-3 etc.

So we can see that the “decimal numbering system” has a base of 10 or modulo-10 (sometimes called MOD-10) with the position of each digit in the decimal system indicating the magnitude or weight of that digit as q is equal to “10” (0 through 9). For example, 20 (twenty) is the same as saying 2 x 101 and therefore 400 (four hundred) is the same as saying 4 x 102.

The value of any decimal number will be equal to the sum of its digits multiplied by their respective weights. For example:  N = 616310 (Six Thousand One Hundred and Sixty Three)  in a decimal format is equal to:

6000 + 100 + 60 + 3 = 6163

or it can be written reflecting the weight of each digit as:

( 6×1000 ) + ( 1×100 ) + ( 6×10 ) + ( 3×1 ) = 6163

or it can be written in polynomial form as:

( 6×103 ) + ( 1×102 ) + ( 6×101 ) + ( 3×100 ) = 6163

Where in this decimal numbering system example, the left most digit is the most significant digit, or MSD, and the right most digit is the least significant digit or LSD. In other words, the digit 6 is the MSD since its left most position carries the most weight, and the number 3 is the LSD as its right most position carries the least weight.

The Binary Numbering System

The Binary Numbering System is the most fundamental numbering system in all digital and computer based systems and binary numbers follow the same set of rules as the decimal numbering system. But unlike the decimal system which uses powers of ten, the binary numbering system works on powers of two giving a binary to decimal conversion from base-2 to base-10.

Digital logic and computer systems use just two values or states to represent a condition, a logic level “1” or a logic level “0”, and each “0” and “1” is considered to be a single digit in a Base-of-2 (bi) or “binary numbering system”.

In the binary numbering system, a binary number such as 101100101 is expressed with a string of “1’s” and “0’s” with each digit along the string from right to left having a value twice that of the previous digit. But as it is a binary digit it can only have a value of either “1” or “0” therefore, q is equal to “2” (0 or 1) with its position indicating its weight within the string.

As the decimal number is a weighted number, converting from decimal to binary (base 10 to base 2) will also produce a weighted binary number with the right-hand most bit being the Least Significant Bit or LSB, and the left-hand most bit being the Most Significant Bit or MSB, and we can represent this as:

Representation of a Binary Number

MSB Binary Digit LSB
28 27 26 25 24 23 22 21 20
256 128 64 32 16 8 4 2 1

We saw above that in the decimal number system, the weight of each digit from right to left increases by a factor of 10. In the binary number system, the weight of each digit increases by a factor of  2 as shown. Then the first digit has a weight of  1 ( 20 ), the second digit has a weight of  2 ( 21 ), the third a weight of  4 ( 22 ), the fourth a weight of  8 ( 23 ) and so on.

So for example, converting a Binary to Decimal number would be:

Decimal Digit Value2561286432168421
Binary Digit Value101100101

By adding together ALL the decimal number values from right to left at the positions that are represented by a “1” gives us:  (256) + (64) + (32) + (4) + (1) = 35710 or three hundred and fifty seven as a decimal number.

Then, we can convert binary to decimal by finding the decimal equivalent of the binary array of digits 1011001012 and expanding the binary digits into a series with a base of  2 giving an equivalent of 35710 in decimal or denary.

Note that in number conversion systems “subscripts” are used to indicate the relevant base numbering system, 10012 = 910. If no subscript is used after a number, then it is generally assumed to be decimal.

Repeated Division-by-2 Method

We have seen above how to convert binary to decimal numbers, but how do we convert a decimal number into a binary number. An easy method of converting decimal to binary number equivalents is to write down the decimal number and to continually divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero.

So for example.  Convert the decimal number 29410 into its binary number equivalent.

This divide-by-2 decimal to binary conversion technique gives the decimal number 29410 an equivalent of 1001001102 in binary, reading from right to left. This divide-by-2 method will also work for conversion to other number bases.

Then we can see that the main characteristics of a Binary Numbering System is that each “binary digit” or “bit” has a value of either “1” or “0” with each bit having a weight or value double that of its previous bit starting from the lowest or least significant bit (LSB) and this is called the “sum-of-weights” method.

So we can convert a decimal number into a binary number either by using the sum-of-weights method or by using the repeated division-by-2 method, and convert binary to decimal by finding its sum-of-weights.

Binary Number Names & Prefixes

Binary numbers can be added together and subtracted just like decimal numbers with the result being combined into one of several size ranges depending upon the number of bits being used. Binary numbers come in three basic forms – a bit, a byte and a word, where a bit is a single binary digit, a byte is eight binary digits, and a word is 16 binary digits.

The classification of individual bits into larger groups are generally referred to by the following more common names of:

Number of Binary Digits (bits)Common Name
1Bit
4Nibble
8Byte
16Word
32Double Word
64Quad Word

Also, when converting from Binary to Decimal or even from Decimal to Binary, we need to be careful that we do not mix up the two sets of numbers. For example, if we write the digits 10 on the page it could mean the number “ten” if we assume it to be a decimal number, or it could equally be a “1” and a “0” together in binary, which is equal to the number two in the weighted decimal format from above.

One way to overcome this problem when converting binary to decimal numbers and to identify whether the digits or numbers being used are decimal or binary is to write a small number called a “subscript” after the last digit to show the base of the number system being used.

So for example, if we were using a binary number string we would add the subscript “2” to denote a base-2 number so the number would be written as 102. Likewise, if it was a standard decimal number we would add the subscript “10” to denote a base-10 number so the number would be written as 1010.

Today, as micro-controller or microprocessor systems become increasingly larger, the individual binary digits (bits) are now grouped together into 8’s to form a single BYTE with most computer hardware such as hard drives and memory modules commonly indicate their size in Megabytes or even Gigabytes.

Number of BytesCommon Name
1,024 (210)kilobyte (kb)
1,048,576 (220)Megabyte (Mb)
1,073,741,824 (230)Gigabyte (Gb)
a very long number! (240)Terabyte (Tb)

Math Formulas ⭐️⭐️⭐️⭐️⭐

.

Hãy bình luận đầu tiên

Để lại một phản hồi

Thư điện tử của bạn sẽ không được hiện thị công khai.


*