Useful Tips

How to add numbers in a binary system

Pin
Send
Share
Send
Send


This online calculator is designed to add subtraction as well as divide and multiply binary numbers online.

Put LIKE and share the link
  • Calculator
  • Instruction manual
  • Theory
  • Story
  • Report a problem

How to use this calculator: The calculator has two input fields for entering binary numbers. The first field is for the first number, the second is for the second, respectively.

Between these two fields, you need to choose which mathematical action you want to perform on them. You can add and subtract as well as multiply or divide fractional binary numbers.

You can use a period or a comma to enter a fractional binary number. After entering the numbers and choosing a mathematical operation on them, click the calculate button. And at the top of the page there will be information with the result of the calculation.

Instruction manual

1. When adding numbers in binary the system the main thing to remember is that it has each two characters - 0 and 1. No other characters can be in it. Consequently, the addition of 2 units of 1 + 1 gives not 2, as in decimal the system , and 10, because 10 is the number following the unit in binary the system .Need to remember the simplest binary addition rules the system : 0 + 0 = 0, 1 + 0 = 0 + 1 = 1, 1 + 1 = 10. These rules are needed in order to add the numbers in binary the system in the column. As you can see, in the case of adding one to one, the unit goes to the next category. Apparently, adding zero to any binary number will not change this number.

2. Huge binary the numbers comfortably stacked in a column. Binary rules the system similar to the addition rules for addition in decimal the system .Let fold the numbers 1111 and 101. We write the number with a smaller number of bits 101 under the number 1111 - the digit of the discharge of one the numbers should be located above the digit of the same category of another the numbers . Now allowed to add these the numbers . In the first digit, 1 + 1 gives 10 - write 0 under the units in the first digit. A unit of 10 goes into the sum of the digits of the second category. In the second category, 1 + 0. Later, adding one from the first digit will also be 10. The unit moves closer to the 3rd digit, and in the second digit of the sum it will also be zero. In the third category, 1 + 1 + 1 (the unit went here!) Gives 11. In the third category, the sum will be 1, and another unit from the numbers 11 will go into the fourth category. The fourth digit has only the number 1111. 1 + 1 = 10. Thus, 1111 + 101 = 10100.

3. The considered example can be written in the column 1111 + 101 —– 10100

Slide captions:

Lesson topic: "Arithmetic operations in positional number systems" Computer Science teacher Fedorchenko Marina ValentinovnaMOU Berezovskaya secondary school with Berezovka Taishet district Irkutsk region Let's remember with you: What is called the number system? What is called the base of the number system? What basis is the binary number system? Indicate which the numbers are written with errors and argue the answer: 1238, 30062, 12AAC0920, 1347610, What is the minimum base the number system should have, if numbers can be written in it: 10, 21, 201, 1201 Does an even binary number end? What digit ends an odd binary number?
Laplace wrote about his attitude to the binary (binary) number system of the great mathematician Leibniz: “In his binary arithmetic Leibniz saw a prototype of creation. It seemed to him that the unit represents the divine principle, and zero represents non-existence, and that the higher being creates everything from non-existence in exactly the same way as the unit and zero in his system express all numbers. ” These words emphasize the versatility of the two-character alphabet. All positional number systems are “the same”, namely, in all of them arithmetic operations are performed according to the same rules:
the same laws of arithmetic are valid: - commutative (translational) m + n = n + mm · n = n · m associative (combinative) (m + n) + k = m + (n + k) = m + n + k (m · n) · k = m · (n · k) = m · n · k distribution (distribution) (m + n) · k = m · k + n · k
the rules of addition, subtraction and multiplication by a column are valid,
rules for performing arithmetic operations are based on tables of addition and multiplication.
Addition in positional number systems Of all positional systems, the binary number system is especially simple. Consider the implementation of basic arithmetic operations on binary numbers. All positional number systems are “the same”, namely, in all of them arithmetic operations are performed according to the same rules: the same ones are true: commutative, associative, distributive, the rules for addition, subtraction and multiplication by a column are valid, the rules for performing arithmetic operations are based to the tables of addition and multiplication.
When adding two digits from right to left in a binary number system, as in any positional system, only one can go to the next digit. The result of adding two positive numbers has either the same number of digits as the maximum of the two terms, or one more digit, but this number can only be one. Consider the examples Solve the examples yourself:
1011012 + 111112
1110112 + 110112
1001100
1010110
When performing the subtraction operation, the smaller one is always subtracted from the larger absolute value and the corresponding sign is put on the result.
Subtraction Consider examples Examples:
1011012– 111112
1100112– 101012
1110
11110
Multiplication in positional number systems The operation of multiplication is performed using the multiplication table according to the usual scheme (used in the decimal number system) with sequential multiplication of the multiplier by the next digit of the factor. Consider the examples of multiplication. We will consider examples We will consider an example on division
Let's solve the examples:
11012 1112

111102:1102=
1011011
101
Homework 1. & 3.1.22. Learn the rules for performing arithmetic operations in the binary number system, learn the tables of addition, subtraction, multiplication. 3. Follow the steps: 110010 + 111.0111110000111-11011000110101,101 * 111 Reflection Today in the lesson, the most informative for me was ... I was surprised that ... I can apply the knowledge gained today in the lesson ...

The binary number system is similar to the usual decimal, except that instead of ten it uses base 2 and only two digits, 1 and 0. The binary system underlies the operation of computers. In binary codes, 1 and 0 are used in order to enable or disable certain processes. Like decimals, binary numbers can be added, and although there is nothing complicated, adding them at first may seem like a daunting task. Before proceeding with the addition of binary numbers, it is necessary to properly understand the concept of a numerical digit.

Draw a bit table consisting of two rows and four columns. In the binary system, base 2 is used, so instead of units, tens, hundreds and thousands in the decimal system (with base 10), the bit values ​​in the binary system are units, deuces, fours and eights. Units will be located in the rightmost column of the table, and eights in the leftmost column.

Write a binary number on the bottom line of the table. In the binary system, only 1 < displaystyle 1> and 0 < displaystyle 0> are used to write numbers.

  • For example, you can write 1 in the category of eights, 1 in the category of fours, 0 in the category of doubles and 1 in the category of units, as a result, you get the following binary number: 1101.

Consider the category of units. If this place is 0, the bit value is 0. If it is 1, the value is 1.

  • For example, in the binary number 1101 in the category of units is 1, so the bit value is 1. Thus, the binary number 1 is equivalent to the decimal number 1.

Consider the category of twos. If there is 0 in this category, the digit value is 0. If, in the category of two, it is 1, the digit value is 2.

  • For example, in the binary number 1101 in the category of doubles is 0, so the bit value is 0. Thus, the binary number 01 is equivalent to the decimal number 1, since in the category of doubles it is 0, and in the category of units 1: 0 + 1 = 1.

Consider the category of fours. If there is 0 in this category, the digit value is 0. If in the fours category it is 1, the digit value is 4.

  • For example, in the binary number 1101, the number of fours is 1, so the bit value is 4. Thus, the binary number 101 is equivalent to the decimal number 5, because it has 1 in the category of fours, 0 in the category of two, and 1: 4 + 0 + in the category of units 1 = 5.

Consider the discharge of eights. If this digit is 0, the digit value is 0. If, however, it is 1 in the digit of eights, the digit value is 8.

  • For example, in the binary number 1101, the digit of eights is 1, so the digit value is 8. Thus, the binary number 1101 is equivalent to the decimal number 13, because it has 1 in the digit of eights 1, 4 in the digit of 4, 2 in the digit of 2, and 1 in the digit of units of 1 : 8 + 4 + 0 + 1 = 13.

Adding Binary Numbers Using Bit Values

Write the numbers in a column and add the corresponding numbers. Since two numbers add up, the sum of the individual digits can be 0, 1 or 2. If the sum is 0, write down the corresponding column 0. If the sum is 1, write 1. If the sum is 2, write down 0 and move 1 to the next column of twos.

  • For example, when adding binary numbers 0111 and 1110 in the column, the units 1 and 0 give a total of 1, so write 1 at the bottom of this column.

Add up the numbers in the doubles column. When adding, it can turn out 0, 1, 2 or 3 (if you transferred 1 from the units column). If the sum is 0, write a 0 under the double in dashes. If the sum is 1, write down at the bottom of column 1. If the sum is 2, write under the bar 0 and transfer 1 to the fours column. If the sum is 3, write down 1 and transfer 1 to the fours column (3 deuces = 6 = 1 deuce and 1 four).

  • For example, when adding binary numbers 0111 and 1110, two units in a column of twos give 2 (two twos, that is, one four), so write under the bar 0 and transfer 1 to the fours.

Add the numbers in the fours column. When adding, it can turn out 0, 1, 2 or 3 (if you transferred 1 from a column of twos). If the sum is 0, write under the line 0 in the category of fours. If the sum is 1, write down at the bottom of column 1. If the sum is 2, write under bar 0 and move 1 to the column of eights. If the sum is 3, write down 1 and transfer 1 to the column of eights (3 fours = 12 = 1 four and 1 eight).

  • For example, when adding binary numbers 0111 and 1110, you should add three units (taking into account the doubles transferred from the column). As a result, we have 3 fours, that is 12, so write down 1 in the column of fours and transfer 1 to the column of eights.

Continue adding up the numbers in each column of digits until you get the final result. For convenience, you can remember that 0 = 0, 1 = 1, 2 = 10 and 3 = 11.

  • For example, when adding binary numbers 0111 and 1110 in a column of eights, you should add two units (taking into account the quadruples transferred from the column). As a result, we get 2, write 0 in the column of eights and transfer 1 to the rank of sixteen. Since there are no digits in the column of sixteen, we write under line 1. Thus, 0111 + 1110 = 10101.

Unit transfer of binary numbers

Write the numbers in a column. Circle pairs of units (digits 1) in the category of units. Remember that the discharge of units is located on the right edge.

  • For example, when adding 1010 + 1111 + 1011 + 1110, you should circle one pair of digits 1.

Consider the category of units. For each pair of digits 1, transfer 1 to the adjacent left column, which corresponds to the category of twos. If in the column of the category of units there is only one digit 1, or after the transfer of pairs there is one extra unit left, write under line 1. If all the units are in pairs or they were not at all, write at the bottom of column 0.

  • For example, since you circled one pair of digits 1, you should transfer 1 to a column of twos, and write 0 under the line in the category of units.

DIVISION OF BINARY NUMBERS

If multiplication is performed by multiple shifts and additions, then division, being the operation of inverse multiplication, is done by multiple shifts and subtractions.

(CORRECT FRACES WITHOUT WHOLE.)

When representing fixed-point numbers, division is possible if the dividend is modulo smaller than the divisor, otherwise the overflow of the bit grid will occur .

As in the case of “manual” division, the digits of the quotient when dividing numbers on the machine are determined (starting from the highest) by successively subtracting the divisor from the remainder obtained from the previous subtraction. However, here the subtraction operation is replaced by the operation of adding the remainder with a negative divisor represented in the reverse or additional code. The sign of the quotient is determined by adding modulo two codes of the signs of the dividend and divisor.

Let us first consider an example of division in the “manual” way.

Here, after each subtraction, the divisor shifts to the right with respect to the dividend. If the residue after subtraction turned out to be positive, 1 is written in the category of the quotient; if negative, zero. In practice, usually the negative remainder is not recorded, just the divider is additionally shifted one more digit to the right and subtracted from the positive remainder.

In machines, instead of shifting the divider to the right, the remainder is shifted to the left, which, in fact, does not change anything.

When dividing with restoring the remainder, the negative remainder is restored by summing with a positive divisor. The recovered residue is shifted to the left by one digit. The divisor is again subtracted from the shifted remainder. The sign of the received balance determines the number of the next category of private. The division process continues until a given number of digits is obtained, which ensures the necessary accuracy of the result.

Let's see how the previous example is solved by car.

The division process begins with a shift of the dividend to the left by one digit, after which a divider is added to it, which is presented, for example, in an additional modified code:

Obviously, when dividing with restoring the remainder in the worst case, for the formation of each category of quotient it is necessary to perform two operations: subtraction (addition in the additional or inverse code) and addition (restoration of the remainder). That is, the execution time of the division operation can be twice as long as the minimum possible.

To reduce the average execution time of the division operation, division is implemented without restoring the remainder, the algorithm of which is as follows.

1) Determine the sign by quotient modulo summation of the two contents of the sign digits of the dividend and the divisor.

2) Subtract the divisor from the dividend. If the remainder is negative, go to step 3. Otherwise, the calculation is completed (overflow has occurred).

3) Remember the remainder sign.

4) Move the remainder one digit to the left.

5) Assign the divisor a sign opposite the sign of the remainder stored in clause 2.

6) Add the shifted remainder and the divisor (taking into account the sign).

7) Assign the number to the quotient the opposite value to the remainder sign code.

8) Repeat steps 3-7 until the required accuracy of calculating the quotient is ensured.

The solution to the above example in this case is carried out according to the following scheme:

With floating point

When performing the division operation on numbers with FLOATING COMMAND, the quotient mantissa is defined as the result of dividing the divisor mantissa by the divisor mantissa, and the quotient order as a result of subtracting the divisor order code from the divisor order code, since

Division of integer non-zero n-bit (not including signed digits) numbers A: B, represented in the direct (for simplicity) code, yields an integer quotient C and an integer remainder 0, which is assigned the sign of the dividend, the sign of the quotient is calculated as the sum modulo two operands A and B.

The division is performed in the following sequence.

1) The divisor B is shifted to the left (normalized), so that there is 1 in the highest information category, the number of shifts S is calculated, the quotient of the division can be no more than (S + 1) bits that are not equal to zero.

2) A (S + 1) module division cycle is performed | A | on IB’l where B "is the normalized B, as a result there is a (S + 1) rank of private, starting with the eldest of (S + 1) junior.

3) The residue Rs + 1 obtained in the last division cycle, if positive, is shifted to the right by S digits, if Rs + 1

Pin
Send
Share
Send
Send