• • • • Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point (real) numbers

Data types represented in binarycoded form Only have 0 & 1 to represent everything can be classified to these categories:
1. Numbers used in arithmetic computation 2. Letters of the alphabet used in data processing 3. Other discrete symbols used for specific purpose Alphanumeric Representation. An alphanumeric character set is a set of elements that includes the 10 decimal digits, the 26 letters of the alphabet and a number of special character such as $, +, and =. 1) The standard alphanumeric binary code: ASCII (American Standard Code for Information Interchange) uses seven bits to code 128 characters. codes must be in binary because registers can only hold binary information.
2) Another alphanumeric code used in IBM equipment; EBCDIC (Extended BCD Interchange Code) that uses 8 bits for each character. BCD (Binary Coded Decimal) represents each individual digit of a decimal number as a group of binary bits; the other formats would convert an entire decimal value to its equivalent binary value. *In the 8421 Binary Coded Decimal (BCD) representation each decimal digit is converted to its 4bit pure binary equivalent.
8 and 9. 3. 1. 7. 2.8421 BCD Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 Decimal Number 0 1 2 3 4 5 6 7 8 9 Number bases. The Decimal Number System (denary representation) uses base 10. It includes the digits from 0 through 9. 5. The weighted values for each position are as follows: . 6. 4. The Base 10 number system uses the digits: 0. The Decimal Number Systems.
the procedure is to separately consider the digits to the left of the decimal point and those to the right of the decimal point. To translate 19. Base 10 to 2. the decimal fraction 0. (4 * 102) + (4 + 101) + (2 * 100) + (2 * 10) + (5 * 102) + (6 * 103) .256 • Most significant digit The leftmost digit (carries the highest value) • Least significant digit The rightmost digit Decimal to Binary Conversion • Decimal notation to binary notation: Integer and fractional parts are handled separately. of 10. Divide the binary number by 2 and consider the remainder which is either 0 or 1. but negative powers of 10 are used. Let us first consider the number 19.256 = (2 * 101) + (5 * 102) + (6 * 103) • A number with both an integer and fractional part has digits raised to both positive and negative powers of 10: 442. Thus.256 stands for 2 tenths plus 5 hundredths plus 6 thousandths: 0.Power of 10 Value • 106 1000000 105 100000 104 10000 103 1000 102 100 101 10 100 1 For example the number 83 means eight tens plus three: 83 = (8 * 10) + 3 • The number 4728 means four thousands. or radix. two ten. plus eight: 4728 = (4 * 1000) + (7 * 100) + (2 * 10) + 8 • The decimal system is said to have a base.687510 to the binary representation. This means that each digit in the number is multiplied by 10 raised to a power corresponding to that digit’s position: 83 = (8 * 101) + (3 * 100) 4728 = (4 * 103) + (7 * 102) + (2 * 101) + (8 * 100) Decimal Fractions • The same principle holds for decimal fractions. seven hundreds.
19.687510 = 10011. 9/2 = 4.687510 19/2=9.10112 Converting to/from Hexadecimal Converting Decimal to Hexadecimal 26 ÷ 16 = 1 with A left over 1 ÷ 16 = 0 with 1 left over 2610 = 1A16.7500 × 2 = 1. The final number is therefore 10011 0.7500 0 0.0000 1 19.5000 × 2 = 1. . remainder 1 most significant digit End of operation.3750 1 (most significant digit after decimal point) 0. remainder 1 4/2 = 2. remainder 0 1/2 = 0. remainder 0 2/2 = 1. remainder 1 least significant digit.5000 1 0.3750 × 2 = 0.6875 × 2 = 1.
a variable whose value may be either 0 or 1.3.7. Octal Number to/from Decimal Number. There are 2 possible values for a bit. Bits are organized into groups of 8 called bytes. there are 28 =256 possible values for a byte.The Binary Number Systems 0. The Binary System • • • Only two digits. about 4. fractional values are represented with negative powers of the radix: 1001.2.5. 1 and 0 Represented to the base 2 The digits 1 and 0 in binary notation have the same meaning as in decimal notation: 02 = 010 12 = 110 • To represent larger numbers each digit in a binary number has a value depending on its position: 102 = (1 * 21) + (0 * 20) = 210 112 = (1 * 21) + (1 * 20) = 310 1002 = (1 * 22) + (0 * 21) + (0 * 20) = 410 and so on. 1 The most basic unit of information that a computer stores is a bit.6.1.101 = 23 + 20 + 21 + 23 = 9. Again. • Example 1 : Octal to Decimal 1228 = (1 x 82) + (2 x 81) + (2 x 80) = (1 x 64) + (2 x 8 ) + (2 x 1) .4. For higher accuracy this is doubled to 8 bytes or 64 bits.62510 The Octal Number System • • • base8 number system In octal numerals each place is a power with base 8 uses the digits 0. and there are 232 different 4 byte words. The most common unit of computer number information is the 4 byte (32 bit) word.3 billion.
The computer’s operating system translates the hexadecimal number into the binary digits that it understands and retrieves the data. A. • • Programmer enters the address using the hexadecimal address of the memory location. 3 101 110 .10012 001 = • • • 1 111 7 101 5 .38 5 = 6 . 5. 100 1002 4 4 Answer : 175. F. C. 8. 1. D. . Example binary to octal notation Given : 1111101. E. B. 7.= 64 + 16 + 2 = 8210 • Example 2 : Decimal to Octal (102810) Answer : 20048 Octal Number to/from Binary Number • • • The binary numbers should be grouped into 3 numbers each as 23 = 8. 3. .448 Example octal to binary notation Given : 56. 4. 6. 011 • Answer : 101110.0112 The Hexadecimal Number System The hexadecimal number system uses the following digits: 0. 2. 9.
Binary Representations • Binary numbers can be stored in 2 different formats: — Unsigned numbers — Signed numbers (signed magnitude. one’s complement.• Much easier for a programmer to tell the computer to go to address 46 than it is 0000 0000 0100 0110. (B37.A84)16 to base 2. called a nibble.A84)16 = (1011 0011 0111 . two’s complement) . 1010 1000 0100)2 • Same principle applies when converting to and from base 8. 1A16 = 1 × 161 + A × 160 = 16 + 10 = 26 Converting Hexadecimal to Binary • replace each digit in base 16 by its binary representation in a 4 bit window: (B37. 2C16 = (216 * 161) + (C16 * 160) = (210 * 161) + (1210 * 160) = 44 Converting to/from Hexadecimal Converting Hexadecimal to Decimal. as follows: 0000 = 0 0100 = 4 1000 = 8 1100 = C 0001 = 1 0101 = 5 1001 = 9 1101 = D 0010 = 2 0110 = 6 1010 = A 1110 = E 11 0111 = 7 1011 = B 1111 = F Because 16 symbols are used. the notation is called hexadecimal and the 16 symbols are the hexadecimal digits Thus. Hexadecimal Notation Binary digits are grouped into sets of four bits. Each possible combination of four binary digits is given a symbol.
+18 = 00010010 18 = 10010010 The remaining bits are used to represent the magnitude of the binary number in the unsigned binary notation. Two representations of zero (+0 and 0) • cause complications for computers checking numbers for equality. Eg. If the sign bit is 1: negative. sign magnitude is rarely used for representing integers Range for a word length of n bits : (2n1 – 1) (2n1 – 1) • • . Need to consider both sign and magnitude in arithmetic • Disadvantage: performing addition or subtraction – we require a special consideration of both signs of the numbers to properly compute the operation.Range for a word length of n bits : 0 (2n – 1) Signmagnitude representation Assign the leftmost (most significant) bit to be the sign bit. Because of these drawbacks. If the sign bit is 0: positive.
d.Add 1 to the result using unsigned binary notation. 1. and the remaining bits are the binary for the integer. Be careful there are enough bits available to represent the number. first represent in binary +A. Compute the value as if it were an unsigned binary value. Complement / flip=00011 Add 1=00100 Compute the value=4 Ans =4 This is the . represent it using the signmagnitude representation. the number is negative.Flip all the 1’s to 0’s and the 0’s to 1’s .Two’s complement Decimal > 2’s complement If A is positive. . the number is positive. Compute the magnitude as an unsigned binary number. a. Flip all the 1’s to 0’s and the 0’s to 1’s b. Add 1 to the result using unsigned binary notation c. If A is negative. The leftmost bit must be 0. The actual value is –B. If the leftmost bit is 0. magnitude of the negative number. say it is B. If the leftmost bit is 1. What is the decimal value of the two’s complement binary value 11100? Leftmost 1=ve. 2.
Two’s complement benefit .g.Arithmetic works easily .One representation of zero .Negating is fairly easy E. 3 = 00000011 Boolean complement gives Add 1 to LSB 11111100 11111101 Range for a word length of n bits : (2n1) (2n1 – 1) .