FRANCAIS francophone2.gif ANGLAIS

 

 

Created the, 12/06/2019

 Updated the, 02/01/2020

Visiteurs N°  


Home
Back to Main Sites New Blog Novelty Search engine Your Shopping Cart For Shopping Your Member Area Bookmarks, Your Favorite Games Static Welcome Page Site in French Web Site in English
Summaries
Basic Electronics Fundamental Technology Test your Knowledge Digital Theoretical Electronics Digital Practical Electronics Digital Electronic Lexicon Data book TTL Data book CMOS TVC Troubleshooting Mathematical
Microcomputers
Theoretical of Microcomputers Test your Knowledge Practical Microcomputers Computer Glossaries
Physical
The light Field of Action Electromagnetic Radiation
Technologies
Classification of Resistances Identification of Resistances Classification of Capacitors Identification of Capacitors
Mathematical Forms
Geometry Physical 1. - Electronic 1. 2. - Electronic 1. 3. - Electrical 1. 4. - Electromagnetism
Access to all our Products
E. T. F. - Volume I - 257 Pages E. T. F. - Volume II - 451 Pages E. T. F. - Volume III - 611 Pages E. T. D. - Volume I - 610 Pages N. B. M. - Volume I - 201 Pages E. T. M. - Volume I - 554 Pages Business at Home Books 34 free pages Our E-books Geometry Software Electronic Components Software
Overview of all our Products
E. T. F. - Volume I - 257 Pages E. T. F. - Volume II - 451 Pages E. T. F. - Volume III - 611 Pages E. T. D. - Volume I - 610 Pages E. T. M. - Volume I - 554 Pages Geometry Software Electronic Components Software
Our Lessons in PDF Formats
Basic Electronics Fundamental Technology Digital Theoretical Electronics Digital Practical Electronics Theoretical of Microcomputers Mathematics
Data Processing
Troubleshooting Win98 and WinXP PC Troubleshooting Glossary HTML and Programs JavaScript (in progress) PHP and Programs Creation of several Sites
Forums
Electronic Forum and Infos Electronic Forum and Poetry
Miscellaneous and others
Form of the personal pages News XML Statistics CountUs JavaScript Editor Our Partners and Useful Links Partnership Manager Our MyCircle Partners Surveys 1st Guestbook 2nd Guestbook Site Directories




Signets :
  Operations in the Octal System    Operations in the Hexadecimal System   Subtraction in Complement to two
  Representation of Numbers with their Sign   Numbers to Several Bytes   Footer


Arithmetic Operations in the Differents Systems :


3. - ARITHMETIC OPERATIONS IN THE DIFFERENTS SYSTEMS

One can obviously perform the four fundamental arithmetic operations (addition, subtraction, multiplication and division) not only in the decimal system but also in other digital systems and in particular in the binary system ; the rules of the decimal system will be valid for these operations.

3. 1. - OPERATIONS IN THE BINARY SYSTEM

To add two binary numbers, we proceed in the same way as in the arithmetic of decimal numbers.

We write the numbers on successive lines by putting them in a column, starting from the right ; then we add the numbers of each column starting with the one on the right.

Example : adding numbers 1100101112 and 10100112 :

Additionner_les_Nombres_Binaires.GIF

Add the numbers 1012, 1112, 12, 1102 :

Additionner_les_Nombres_Binaires_2.GIF

It will be noted that in the third column the following addition is : 1 + 1 + 1 + 1 with a hold of 10.

In this type of case, the last deduction consists in putting "0" in the first column located immediately to the left and "1" in that which follows.

Now let's see the subtraction ; this can also be done according to the traditional rule of column layout, starting from the right and possibly using borrowing units in each column.

In particular, when the number of the first term is "0" and that corresponding to the second term is "1", in the first term we reverse all the digits located on the left until the first 1 included, and we put "1" in front the initial "0" to form the binary number 10. From this number, we then subtract the number 1 from the second term, remembering that in the binary system, we have : 10 - 1 = 1.

Example : subtract from 101110110002 the number 11001112 :

Soustraction_Binaire.GIF

Addition and subtraction are the two most important and most used operations in calculators.

Multiplication and division, like the preceding operations, are always calculated according to traditional arithmetic rules; they are little used ; we will however see an example of calculation for each operation.

Example of multiplication :

Multiplication_Binaire.GIF

Example of division :

Division_Binaire.GIF

The two previous operations should not present any difficulty since the calculations consist mainly in multiplying binary digits (that is to say 0 x 0 = 0 ; 0 x 1 = 0 ; 1 x 0 = 0 ; 1 x 1 = 1) and directly subtract two numbers for division.

HAUT DE PAGE 3. 2. - OPERATIONS IN THE OCTAL SYSTEM

In this section we will look at the addition and subtraction operations in the octal system. As for the binary system, we apply the same rules for octal numbers.

However, in this case, we will have the retainer "1" on the left each time the sum exceeds 7 and it would be good to use the table in Figure 4.

Tableau_Octal.GIF

To add two octal digits, we look for these digits in the table : one at the start of the column, the other at the start of the line ; the sum is in the box corresponding to the crossover between column and row.

For example, if we have to add the octal digits 7 and 5, we look for the sum in the box located at the intersection of column 7 and line 5. In this box, we find 14. Thus, in the octal system, we'll have :

7 + 5 = 14

Octal addition example :

Addition_Octale.GIF

For the subtraction, after having transferred by the usual method the possible loans, one uses the table of Figure 4, while proceeding in opposite order : First, one reads at the beginning of column the figure of the second term ; then we look in this same column for the number of the first term (possibly formed by placing the borrowing unit in front of it) ; then read the difference at the start of the line.

Exemple de soustraction octale :

 Soustraction_Octale.GIF

HAUT DE PAGE 3. 3. - OPERATIONS IN THE HEXADECIMAL SYSTEM

Let us now extend the arithmetic rules to hexadecimal numbers, remembering that there will be a deduction of 1 in the left column each time the sum exceeds F, (F = 1510).

If two hexadecimal digits have to be added, the table in Figure 5 will be used with the same method as that in Figure 4 for octal calculations.

Tableau_Hexadecimal.GIF

Example of hexadecimal addition :

Addition_Hexadecimale.GIF

For the subtraction, one can apply the same rule as that used in the octal system.

Example of hexadecimal subtraction :

Soustraction_Hexadecimale.GIF

HAUT DE PAGE 3. 4. - SUBTRACTION IN COMPLEMENT TO TWO

The circuits of the microcomputer cannot directly subtract binary numbers, but only add them. It is therefore necessary to find a method to transform subtractions into additions. The procedure is relatively simple if we use the two's complement relating to the second term. To know the complementation method, we must first see how it appears in the decimal system and more precisely, in the subtraction :

 7 - 4 = 3

By adding 10 to the two terms of equality, this does not change ; So we have :

7 - 4 + 10 = 3 + 10

We can write the above expression as follows :

7 + (10 - 4) = 10 + 3

Now, by performing the subtraction that we wrote in parentheses, we get :

7 + 6 = 13

By removing the "1" from "13", we get 3, that is to say exactly the difference between "7" and "4". The amount "10 - 4 = 6" is called the complement to "10" of "4". In the same way, 3 will be the complement to "10" of "7" and so on.

We have therefore seen that by substituting the second term ("4" in the example cited) for its complement with "10", the subtraction can be done by adding the two terms while ignoring the carry.

Example :

Let us carry out the subtraction 6 - 2. The complement to "10" of 2 is 10 - 2 = 8 ; therefore :

6 + 8 = 14

Ignoring the restraint, as we have already said, we have 4, difference between 6 and 2.

We can notice that the problem has not been totally solved since to obtain the complement to ten, it is necessary to subtract anyway and to compute "10 - 4" is not simpler than "7 - 4". But in binary code the calculations change, in fact, in this code, the equivalent of the complement to ten is the complement to two and to introduce it, it is necessary to make an intermediate passage, which is the complement to 1 of the number binary chosen. This complement is obtained by inverting all the bits of the number, that is to say by putting 0 in place of 1 and vice versa.

Thus, the complement to 1 of 10 01 11 01 is 01 10 00 10.

This is an operation that can be done easily in digital circuits because, to complement a number it is sufficient to send it to an inverter circuit that will act on each bit of the number. Then, we get the complement to 2 by simply adding "1" to the previous complement.

For example, the complement to "2" of 10 01 11 01 is :

Complement_a_2.GIF

Another rule makes it possible to obtain the complement to "2", it is stated as follows :

We copy the number whose complement we want to find at "2" from right to left until the first "1" encountered ; we then complete all the bits to its left.

For example, let's add "2" to the binary number 10  110 100.

Starting from the right, we have two "0" and a "1" which we simply copy ; from this moment, we finish writing the number by completing each bit.

Complement_a_2_autre_methode.GIF 

At this point, it is easy to understand how a binary subtraction can be transformed into an addition.

Let's see the following example :

Soustraction_Binaire_2.GIF

When doing the operation by adding the first term to the complement to "2" of the second term, the final carry will not be taken into account as for the decimal system seen above. We will therefore obtain :

 Addition_Binaire_avec_Retenue_a_negliger.GIF

So the difference is : 0 1 1 1.

HAUT DE PAGE 3. 5. - REPRESENTATION OF NUMBERS WITH THEIR SIGN

To represent a number in computers, we use a given quantity of bits (8, 16, 32).

With 8 bits (1 byte), we obtain all the combinations between 0 0 0 0 0 0 0 02 and 1 1 1 1 1 1 1 12, that is to say between 010 and 25510.

If we want to increase the field of the numbers represented, it is necessary to add other bits ; for example, with 16 bits (equivalent to 2 bytes), all the decimal numbers can be represented between 010 and 6553510 ; with 32 bits (4 bytes), we can represent all the decimal numbers that go from 010 to 4 294 967 29510.

In all cases, it is always natural numbers, but considering the first bit to the left of a byte or a group of bytes, we can also represent the signed numbers, that is to say positive numbers (identified by the + sign) and negative numbers (identified by the - sign).

You can associate the 0 with the + sign and the 1 with the - sign. Thus, the decimal number + 23 will be expressed, in the binary system, as follows :

Valeur_Absolue_du_nombre_Positif.GIF

The decimal number - 23, still in the binary system, will however be expressed as follows :

Valeur_Absolue_du_nombre_Negatif.GIF

By taking into account the sign, the field of the numbers is modified because from 0 to 255 one passes to - 127 to + 127 but the amplitude remains constant at 256 values.

Let's see, for example, the numeric field of a byte (8 bits). This can include all the natural numbers from 0 to 255 or all the relative numbers from - 127 to + 127 (Figure 6).

Figure 6. - Numeric fields with sign.
Hexadecimal field Decimal field Binary field (in sign and absolute value)
7F + 127 0 1 1 1 1 1 1 1
7E + 126 0 1 1 1 1 1 1 0
7D + 125 0 1 1 1 1 1 0 1
03 + 3 0 0 0 0 0 0 1 1
02 + 2 0 0 0 0 0 0 1 0
01 + 1  0 0 0 0 0 0 0 1
00  + 0 0 0 0 0 0 0 0 0
80 - 0 1 0 0 0 0 0 0 0
81 - 1 1 0 0 0 0 0 0 1
82 - 2 1 0 0 0 0 0 1 0
FE - 126 1 1 1 1 1 1 1 0
FF - 127 1 1 1 1 1 1 1 1


Note : The hexadecimal field numbers are obtained by writing the hexadecimal value of the two nibbles that make up the corresponding number of the binary field (byte).

By observing the column entitled binary field (in sign and absolute value) of the table of Figure 6, we notice that we have two different codes for the 0 : 0000 0000, that we could also write + 0, and 1000 000 that we could write - 0.

Thus, by including the two codes of 0, the field strength is always 256 numbers, whether in the case of natural numbers or in the case of relative numbers.

This new binary number system is progress, but is not yet satisfactory. As a demonstration, let us carry out the following addition, using the binary representation with sign :

Addition_Binaire.GIF 

The result 1 0 0 0 1 1 0 0 is equivalent to - 12 and not to + 2, as it should be. The binary addition of numbers with their sign therefore does not automatically give us the exact result within the adopted system.

It is therefore necessary to modify it as follows :

We always represent positive numbers according to the normal binary code (the + sign is still a 0) ; negative numbers, on the other hand, are represented by using the two's complement of their absolute value and by keeping bit 1 as bit representing the sign - (Figure 7).

Figure 7. - Numeric fields with sign and two's complement of negative binary value.
Hexadecimal field Decimal field Binary field (in two's complement)
7F + 127 0 1 1 1 1 1 1 1
7E + 126 0 1 1 1 1 1 1 0
7D + 125 0 1 1 1 1 1 0 1
  4  + 4 0 0 0 0 0 1 0 0
 3 + 3 0 0 0 0 0 0 1 1
 2 + 2 0 0 0 0 0 0 1 0
 1 + 1 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
FF - 1 1 1 1 1 1 1 1 1
FE - 2 1 1 1 1 1 1 1 0
FD - 3 1 1 1 1 1 1 0 1
83 - 125 1 0 0 0 0 0 1 1
82 - 126 1 0 0 0 0 0 1 0
81 - 127 1 0 0 0 0 0 0 1
80 - 128 1 0 0 0 0 0 0 0


In the previous example, + 7 will still be represented by 0 0 0 0 0 1 1 1 ; the negative number - 5 will however be expressed by 1 1 1 1 1 0 1 1.

With the new representation, let's do the sum again :

With this new method, we obtain the exact sum 0 0 0 0 0 0 1 0 (we do not take the withholding into account).

So far, there is nothing new compared to the subtraction done with the two's complement method. However, consider another case.

Addition_Binaire_avec_Nouvelle_Methode_2.GIF

If we examine the result, we first see that it represents a negative number, the first bit being at 1.

Furthermore, 1 1 1 1 1 0 0 is the two's complement of 4. By interpreting the number according to the new method, we deduce that the exact result is - 4.

The numbers processed by computers are generally coded by this method. Indeed, in this way, the result of an addition between relative numbers is automatically exact (if there is no overflow) and the subtraction is to be considered as an addition of relative numbers.

For example, if we have to subtract - 2 from + 4, we transform the operation, by adding the numbers + 4 and + 2, because + 4 - (- 2) = + 4 + 2.

We obtain :

Addition_Binaire_avec_Nouvelle_Methode_3.GIF

The sum 0 0 0 0 0 1 1 0 is equivalent to 6, the decimal value of the result of the subtraction.

HAUT DE PAGE 3. 6. - NUMBERS WITH SEVERAL BYTES

In microcomputer memory, the boxes available to store a number generally have a given length : 1 byte, for example, often corresponds to an 8 bits number.

Suppose that one has to record a number formed by an amount of bits greater than the eight bits which constitute a byte. In such cases, two or more bytes are used to store this number, and two or more 8 bits locations for this single number must therefore be reserved in memory.

In the memory, the number will preferably be stored in contiguous boxes, as seen in the following diagram (nothing however prohibits having the two bytes in non-adjacent boxes).

Cases_Memoire.GIF

How will we perform operations with numbers occupying two or more bytes in memory ?

It should indeed be known that the computer can work only with numbers having a given length.

Suppose we want to add two numbers of 2 bytes using a computer designed for 8 bits numbers.

The addition, in this case, must be carried out in two stages : a first stage for byte 0 and a second stage for byte 1.

Double_Additions_Binaires.GIF

First, the computer adds the right parts of the two terms (the least significant) ; secondly, it adds up the parts on the left, taking into account the possible deduction, produced by the preceding sum.

Such a retention is stored in an appropriate box of the central unit to be able to be added to the least significant bit of the following byte, or else to be used for example as an indicator of overflow (overshoot) when the capacity of the computer.

In the tables of Figures 6 and 7, in addition to the binary field and the decimal field, the corresponding hexadecimal field is reported ; the hexadecimal representation is however not used in the last calculations because one wanted to show simply the arithmetical problems imposed by the operational characteristics of the computer.

Hexadecimal numbers and sometimes even octal numbers are used exclusively by the programmer to substitute binary expressions to avoid reading and transcription errors. We will talk about these numbers later.

Test your knowledge of this 3rd theory before continuing the other lessons by clicking here.







Nombre de pages vues, à partir de cette date : le 27 Décembre 2019

compteur visite blog gratuit


Mon audience Xiti



Send an email to Corporate Webmaster for any questions or comments about this Web Site.

Web Site Version : 11. 5. 12 - Web Site optimization 1280 x 1024 pixels - Faculty of Nanterre - Last modification : JANUARY 02, 2020.

This Web Site was Created on, 12 JUNE 2019 and has Remodeled, in JANUARY 2020.