Overflow - PowerPoint PPT Presentation

About This Presentation
Title:

Overflow

Description:

Easy to convert but the arithmetic is hard Suitable as interface such as keyboard input and digital reading Binary Coded Decimal (BCD) Example: Notes: BCD is ... – PowerPoint PPT presentation

Number of Views:118
Avg rating:3.0/5.0
Slides: 34
Provided by: FSK6
Category:

less

Transcript and Presenter's Notes

Title: Overflow


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)

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

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)
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
5
Fixed Point Number
  • Generally, other locations in binary point
    position
  • Example If two fraction bit is used, we can
    represent

fraction
Binary point
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)

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

Mantissa exponent
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

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

10
Arithmetic with Floating Point Number
  • Example

(Normalization)
11
Arithmetic with Floating Point Number
  • ADDITION
  • Steps
  • Equalize their exponent
  • Add their mantissa
  • Normalize them

12
Arithmetic with Floating Point Number
  • Example
  • (0.12x102)10 (0.0002x104 ) 10
  • (0.12x102) 10 (0.02x102) 10
  • (0.120.02) 10 x 102
  • (0.14x102 ) 10

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.

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
Decimal Digit
15
Binary Coded Decimal (BCD)
  • Example
  • Notes BCD is not similar to binary
  • Example (243)10(11101010)2

Decimal Digit
Decimal Digit
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
17
Gray Code
18
Gray Code
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

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

21
Other Decimal Code
  • Self compliment code excess-3 code, 84-2-1,
    2421
  • Error detection code Biquinary code (bitwo,
    quinaryfive)

22
Self Compliment Code
  • Example Excess-3, 84-2-1, 2421
  • Code represented by coupled compliment-digit
    which compliment each other

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

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

25
Alphanumeric Code
  • ASCII Table

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

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

28
Error Detection Code
  • Parity Bit can detect odd error and not even
    error (if odd is set)
  • Example For odd parity number
  • 10011gt10001 (detected)
  • 10011gt10101 (not detected)
  • Parity bit can also be used on data block

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 nk bit
  • Number the bit 1 on bit nk
  • Every parity bit is on the number range

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

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

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

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 C10000 therefore no error, if
    otherwise C8 C4 C2 C1 show position, there is an
    error for only one bit
  • Example
Write a Comment
User Comments (0)
About PowerShow.com