Presentation is loading. Please wait.

Presentation is loading. Please wait.

Revision Language generations Two’s and One’s Complement and Sign and Magnitude.

Similar presentations


Presentation on theme: "Revision Language generations Two’s and One’s Complement and Sign and Magnitude."— Presentation transcript:

1 Revision Language generations Two’s and One’s Complement and Sign and Magnitude

2 Language Generations: Evolution of Programming Languages

3

4 First Generation The first generation of languages was very difficult to understand and also to code This language was based on machine code language, hence the programmer would need to use binary For this particular generation, punched tape was used, where a hole would represent a 1 and no-hole meant a 0.

5 Second Generation / Assembly Language The second generation language, was also based on machine code, This language was much easier as it used mnemonics (short words) Programming was much easier because the programmer did not have to remember a list of binary digits Keywords are used in this language such as ADD, SUB, JMP, MUL, etc

6 Third Generation / High-level Language The third generation of languages was a very big improvement from the second generation This generation incorporated the use of English-like statements Examples of 3GLs are C, C++, Pascal and JAVA.

7 Examples of the 3 rd Generations FORTRAN - mathematics formulas, scientific problems, engineering problems COBOL – business oriented BASIC – very easy to understand, ideal to learn programming PASCAL – mostly used for teaching purposes C – used to write operating systems, database management system, scientific applications LISP – artificial intelligence LOGO – teach children problem-solving and programming skills C ++ - An improved C, very popular and powerful JAVA – Very popular and powerful, also cross-platform

8 Fourth Generation The fourth generation language is a is much closer to the human language A typical example of the ease of use of 4th generation languages is the creation of a GUI. To create a GUI in JAVA would be quite difficult because of the code required for each component, with any 4GL creating an interface is a simple matter of drag and drop This generation is used a lot with databases

9 Fifth Generation Lastly we have the fifth generation languages, which are the closest to the human language This generation is used in artificial intelligence

10 Number Systems: Two’s and One’s Complement and Sign and Magnitude

11 Complementation Complementation is used to represent positive and negative numbers in binary This system requires numbers to be represented by a fixed register size. There are two forms of complementation, one’s complement and two’s complement.

12 Ones Complement One’s complement is used to represent negative numbers Lets say we have 45 10 When using 8 bits 45 10 = 00101101 2 If we change 45 10 to -45 10 The binary representation changes by converting 0s to 1s and 1s to 0s; 00101101 2 11010010 2. after ones complement

13 Examples DecimalUnsigned Binary One’s Complement -109 10 1101101 2 0010010 2 -229 10 11100101 2 00011010 2 DecimalUnsigned Binary One’s Complement -89 10 01011001 2 10100110 2 -64 10 1000000 2 0111111 2 -89 10 -64 10

14 Two’s Complement Two’s complement allows us to perform subtractions with binary numbers With two’s complement we start converting 1s to 0s and 0s to 1s after the first 1 Lets take the previous example of -45 10, DecimalUnsigned Binary Two’s complement -45 10 00101101 2 11010011 2

15 Examples DecimalBinaryTwo’s Complement -10 10 00001010 2 11110110 2 -42 10 00101010 2 11010110 2 -55 10 00110111 2 11001001 2 -60 10 00111100 2 11000100 2 -55 10 -60 10

16 Sign and Magnitude When we have a fixed register we might want to store our binary number in a certain way The three ways are using; 1. sign and magnitude (first digit is 0 = positive, first digit is1 = negative) 2. one’s complement 3. two’s complement.

17 Example Lets say I have an 8 bit register and want to store -14 10 The number changes since it is negative, we first change it to binary = 00001110 2 Sign and Magnitude 10001110 Note that the fist digit is 1 because in this case 14 is a negative number. One’s Complement 11110001 In this case we simply applied NOT on the binary value of 14. Two’s Complement 11110010 We change the binary number 14 into two’s complement

18 Example 2 Lets say I have an 8 bit register and want to store 14 10 The number does not change since it is a positive number, we first change it to binary = 00001110 2 Sign and Magnitude 00001110 Note that the fist digit is 0 because in this case 14 is a positive number. One’s Complement 00001110 In this case we simply leave the binary number the same Two’s Complement 00001110 In this case we simply leave the binary number the same


Download ppt "Revision Language generations Two’s and One’s Complement and Sign and Magnitude."

Similar presentations


Ads by Google