180 likes | 307 Views
Revision. Language generations Two’s and One’s Complement and Sign and Magnitude. Language G enerations: Evolution of Programming Languages . First Generation . The first generation of languages was very difficult to understand and also to code
E N D
Revision Language generations Two’s and One’s Complement and Sign and Magnitude
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 3rd 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 4510 • When using 8 bits 4510 = 001011012 • If we change 4510 to -4510 The binary representation changes by converting 0s to 1s and 1s to 0s; 001011012 110100102. after ones complement
Examples -8910 -6410
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 -4510,
Examples -5510 -6010
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; • sign and magnitude (first digit is 0 = positive, first digit is1 = negative) • one’s complement • two’s complement.
Example • Lets say I have an 8 bit register and want to store -1410 • The number changes since it is negative, we first change it to binary = 000011102
Example 2 • Lets say I have an 8 bit register and want to store 1410 • The number does not change since it is a positive number, we first change it to binary = 000011102