Revision Language generations Two’s and One’s Complement and Sign and Magnitude
Language Generations: Evolution of Programming Languages
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.
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
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.
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
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
Fifth Generation Lastly we have the fifth generation languages, which are the closest to the human language This generation is used in artificial intelligence
Number Systems: Two’s and One’s Complement and Sign and Magnitude
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.
Ones Complement One’s complement is used to represent negative numbers Lets say we have When using 8 bits = If we change to The binary representation changes by converting 0s to 1s and 1s to 0s; after ones complement
Examples DecimalUnsigned Binary One’s Complement DecimalUnsigned Binary One’s Complement
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 , DecimalUnsigned Binary Two’s complement
Examples DecimalBinaryTwo’s Complement
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.
Example Lets say I have an 8 bit register and want to store The number changes since it is negative, we first change it to binary = Sign and Magnitude Note that the fist digit is 1 because in this case 14 is a negative number. One’s Complement In this case we simply applied NOT on the binary value of 14. Two’s Complement We change the binary number 14 into two’s complement
Example 2 Lets say I have an 8 bit register and want to store The number does not change since it is a positive number, we first change it to binary = Sign and Magnitude Note that the fist digit is 0 because in this case 14 is a positive number. One’s Complement In this case we simply leave the binary number the same Two’s Complement In this case we simply leave the binary number the same