1 / 33

Overflow

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). Overflow.

elani
Download Presentation

Overflow

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Overflow • Signed binary is in fixed range • -2n-1 2n-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 : -2n-1 2n-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 = 5 1001 = -7 0100 = 4 1010 = -6 ----------- ----------- 1001 10011 MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  3. Overflow • Example: Binary number 4-bit (second complement) • Range : -2n-1 2n-1-1 • Range : (1000)2s(0111) 2s • Range : (-8) 10 (+7)10 (Overflow exist) (ignore final carry) (Overflow exist) 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 fraction • Generally, other locations in binary point position • Example: If two fraction bit is used, we can represent: Binary point 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.23X1023(really large number) • 0.1239X10-10(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 MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  8. Floating Point Number • Mantissa always in normalize form: (base 10) 23X1021 is normalized to 0.23X1023 (base 10) –0.0017X1021 is normalized to -0.17X1019 (base 10) 0.01101X103 is normalized to 0.1101X102 • 16-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.12x102)10 + (0.0002x104 ) 10 = (0.12x102) 10 +(0.02x102) 10 = (0.12+0.02) 10 x 102 = (0.14x102 ) 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) Decimal Digit • 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) Decimal Digit • Example: Notes: BCD is not similar to binary Example: (243)10=(11101010)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 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 10110 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 10110 to binary code MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  21. Other Decimal Code • Self compliment code: excess-3 code, 84-2-1, 2*421 • Error detection code: Biquinary code (bi=two, quinary=five) MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  22. Self Compliment Code • Example: Excess-3, 84-2-1, 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: P1= parity for bit {3,5,7,9,11} P2= parity for bit {3,6,7,10} P4= parity for bit {5,6,7,12} P8= parity for bit {9,10,11,12} MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  32. Error Detection Code • Given 8-bit number: 1100 0100 • Assume even parity is P1= parity for bit {3,5,7,9,11} = 0 P2= parity for bit {3,6,7,10} = 0 P4= parity for bit {5,6,7,12} = 1 P8= parity for bit {9,10,11,12} = 1 MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

  33. Error Detection Code • To check error, execute checking code C1= XOR {1,3,5,7,9,11} C2= XOR {2,3,6,7,10} C4= XOR {4,5,6,7,12} C8= XOR {8,9,10,11,12} If C8 C4 C2 C1=0000 therefore no error, if otherwise C8 C4 C2 C1 show position, there is an error for only one bit • Example MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR

More Related