MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1 2 n-1 If the answer for addition/subtraction more than the range, it is overflow Two situation where overflow can happen: –Positive + positive = negative (enough n-bit) –Negative + negative = positive(more than n-bit)
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 2 Overflow Example: Binary number 4-bit (second complement) Range : -2 n-1 2 n-1 -1 Range : (1000) 2s (0111) 2s Range : (-8) 10 (+7) 10 Two situation where overflow can happen: –Positive + positive = negative (enough n-bit) –Negative + negative = positive(more than n-bit) 0101 = = = =
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 3 Overflow Example: Binary number 4-bit (second complement) Range : -2 n-1 2 n-1 -1 Range : (1000) 2s (0111) 2s Range : (-8) 10 (+7) 10 (Overflow exist) (ignore final carry)
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 4 Fixed Point Number Signed number and unsigned number representation is given in fixed point number Binary point is assumed to have fixed location, if it is located at the end of the number It can represent integer number between –128 to 127 (for 8-bit binary complement) Binary point
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 5 Fixed Point Number Generally, other locations in binary point position Example: If two fraction bit is used, we can represent: Binary point fraction
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 6 Floating Point Number Fixed point number has limited range To represent extremely large or extremely small number, we use floating point number (like scientific number) Example: 0.23X10 23 (really large number) X (really small number)
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 7 Floating Point Number Floating point number is divided into three parts mantissa, base and exponent Base always fixed in number system Therefore, only need mantissa and exponent Mantissaexponent
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 8 Floating Point Number Mantissa always in normalize form: (base 10) 23X10 21 is normalized to 0.23X10 23 (base 10) –0.0017X10 21 is normalized to -0.17X10 19 (base 10) X10 3 is normalized to X bit floating point number might contain 10-bit mantissa and 6-bit exponent More exponent, the greater its range More mantissa, the greater its persistence
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 9 Arithmetic with Floating Point Number Arithmetic with floating point number is much difficult MULTIPLICATION The steps: –multiply with the mantissa –Add its exponent –normalized
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 10 Arithmetic with Floating Point Number Example (Normalization)
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 11 Arithmetic with Floating Point Number ADDITION Steps: –Equalize their exponent –Add their mantissa –Normalize them
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 12 Arithmetic with Floating Point Number Example: (0.12x10 2 ) 10 + (0.0002x10 4 ) 10 = (0.12x10 2 ) 10 +(0.02x10 2 ) 10 =( ) 10 x 10 2 =(0.14x10 2 ) 10
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 13 Binary Coded Decimal (BCD) Decimal number is normally used by human. Binary number is normally used by computer. It is expensive to exchange between each other. If used only little calculation, we can use coding scheme for decimal number. One of the scheme is BCD, or also called 8421 code. Which represent every decimal digit with 4- bit binary code.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 14 Binary Coded Decimal (BCD) There are code which is not used, e.g. (1010) BCD,(1011) BCD,….,(1111) BCD. This code is said to be an error. Easy to convert but the arithmetic is hard Suitable as interface such as keyboard input and digital reading Decimal Digit
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 15 Binary Coded Decimal (BCD) Example: Notes: BCD is not similar to binary Example: (243) 10 =( ) 2 Decimal Digit
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 16 Gray Code No weight Only one bit change from one code number to the others Suitable for error detection Decimal Binary Gray Code
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 17 Gray Code
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 18 Gray Code
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 19 Convert Binary Code to Gray Code Fixed MSB From left to right, add each coupled binary code bit next to each other to get Gray code bit, ignore carry Example: convert binary to Gray code
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 20 Convert Gray Code to Binary Code Fixed MSB From left to right, add each coupled binary code executed with Gray code bit at the next position, ignore carry Example: convert Gray to binary code
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 21 Other Decimal Code Self compliment code: excess-3 code, , 2*421 Error detection code: Biquinary code (bi=two, quinary=five)
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 22 Self Compliment Code Example: Excess-3, , 2*421 Code represented by coupled compliment-digit which compliment each other
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 23 Alphanumeric Code Part of numbers, computer also handle textual data Set which always used includes: Letters:‘A’,…..,‘Z’ and ‘a’,…..,‘z’ Digits: ‘0’,…..,‘9’ Special Characters: ‘$’, ‘ ’, ‘!’, ‘,’, ‘.’,…. Not Printable: SOH, NULL, BELL,…. Most of the time, it is represented by 7 or 8-bit
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 24 Alphanumeric Code Two standard that are frequently used ASCII (American Standard Code for Information Interchange) EBCDIC (Extended BCD Interchange Code) ASCII: 7-bit, add with parity bit for error detection (odd,even parity) EBCDIC: 8-bit
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 25 Alphanumeric Code ASCII Table
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 26 Error Detection Code Error can exist in transmission. It must be detected so that retransmission can be requested With binary number, mostly exist 1-bit error. Example: 0010 is transmitted incorrectly as 0011, or 0000, or 0110, or 1010 Biquinary using additional 3-bit to detect error. For one error detection, only one extra bit is needed
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 27 Error Detection Code Parity Bit –Even parity: number of bit 1 is even –Odd parity: number of bit 1 is odd Example: Odd parity
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 28 Error Detection Code Parity Bit can detect odd error and not even error (if odd is set) Example: For odd parity number 10011=>10001 (detected) 10011=>10101 (not detected) Parity bit can also be used on data block
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 29 Error Detection Code Sometimes, it is not enough to detect code, we need to correct it Error correction is expensive in practical, we only need to use one bit error correction Popular technique: Hamming Code –Add k-bit to n-bit number to produce n+k bit –Number the bit 1 on bit n+k –Every parity bit is on the number range
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 30 Error Detection Code E.g: For 8-bit number, we need 4 parity bit 12 bit number are 0001,0011,…,1100. Every 4 bit parity is used to detect group of bit. Every parity bit is for themselves and has bit ‘1’ on certain position bit
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 31 Error Detection Code Therefore: P 1 = parity for bit {3,5,7,9,11} P 2 = parity for bit {3,6,7,10} P 4 = parity for bit {5,6,7,12} P 8 = parity for bit {9,10,11,12}
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 32 Error Detection Code Given 8-bit number: Assume even parity is P 1 = parity for bit {3,5,7,9,11}= 0 P 2 = parity for bit {3,6,7,10}= 0 P 4 = parity for bit {5,6,7,12}= 1 P 8 = parity for bit {9,10,11,12}= 1
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 33 Error Detection Code To check error, execute checking code C 1 = XOR {1,3,5,7,9,11} C 2 = XOR {2,3,6,7,10} C 4 = XOR {4,5,6,7,12} C 8 = XOR {8,9,10,11,12} If C 8 C 4 C 2 C 1 =0000 therefore no error, if otherwise C 8 C 4 C 2 C 1 show position, there is an error for only one bit Example