Hexadecimal - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Hexadecimal

Description:

Problem with sign-magnitude. To perform math. ... Represent the following values in binary bits using Sign-Magnitude and Two's Complement ... Sign-magnitude ... – PowerPoint PPT presentation

Number of Views:1012
Avg rating:3.0/5.0
Slides: 19
Provided by: shantil
Category:

less

Transcript and Presenter's Notes

Title: Hexadecimal


1
Hexadecimal
  • Base 16
  • Uses 16 symbols to represent all 16 hex digits
  • 0 .. 9 and A, B, C, D, E, F (for values 10 to
    15)
  • Decimal Hex Binary (4 bits)
  • 0 0 0000
  • 1 1 0001
  • 2 2 0010
  • 3 3 0011
  • 4 4 0100
  • 5 5 0101
  • 6 6 0110 (contd.)

2
Hexadecimal
  • Decimal Hex Binary (4 bits)
  • 7 7 0111
  • 8 8 1000
  • 9 9 1001
  • 10 A 1010
  • 11 B 1011
  • 12 C 1100 (contd.)

3
Hexadecimal
  • Decimal Hex Binary (4 bits)
  • 13 D 1101
  • 14 E 1110
  • 15 F 1111

4
Conversions between Binary and Hexadecimal
  • Hexadecimal ? Binary
  • Expand each Hex. Symbol to four binary bits
  • Examples
  • 3 F 9 5 0 C
  • 0011 1111 1001 0101 0000 1100

5
Binary ? Hexadecimal
  • Pack (from right to left) each group of 4-bit
    binary into one Hex. Symbol
  • Examples
  • 100 1101 11102 1010 0000 00112
  • 4 D E16 A 0 316

6
In Class Exercises
  • Convert the following Binary to Hex.
  • 1101101102
  • 11010101002
  • 1111111112
  • Convert the following Hex. To Binary
  • 83416
  • 50D16
  • 7A016

1 B 6 3 5 4 1 F F
1000 0011 0100 0101 0000 1101 0111 1010 0000
7
Adding Binary Numbers
  • Binary addition facts
  • 1 1 0 0
  • 1 0 1 0
  • 10 1 1 0
  • Example 01011100
  • 00110110
  • 10010010

8
In Class Exercises
  • Perform the following binary additions
  • 10101110 11001100
  • 00000011 00110011
  • 10110001 11111111
  • 11001111 11110001
  • 00000001 00001001
  • 11010000 11111010

9
Representing Negative Values
  • Negative values can be represented in Binary for
    use by computers.
  • Several different ways of representing negative
    values can be used.
  • We will discussed two only
  • Sign Magnitude
  • Twos Complement

10
Sign-Magnitude
  • Sign Bit Absolute value
  • 1 for negative
  • 0 for positive
  • Therefore, the above binary represents -5

0
0
1
0
0
0
1
1
11
Problem with sign-magnitude
  • To perform math., adjustments are needed to
    obtain the correct answers
  • 7 00000111
  • 5 10000101
  • 2 10001100
  • Which means -12

12
Twos Complement
  • negative decimal integer ?
  • Twos complement binary number
  • 1. Take absolute value of negative decimal
    integer
  • 2. Convert it to binary number
  • 3. Change all the 1s to 0 s and 0 s to 1s
  • (1s complement)
  • 4 Add 1 to the result of step 3
  • (2s complement)

13
2s Complement Examples
  • To represent 5 in binary using 2s complement
  • ? binary for positive 5 00000101
  • ? 1s complement 11111010
  • ? 2s complement (adding 1 to result from step
    2) 11111010
  • 1
  • Answer 11111011

14
In Class Exercises
  • Represent the following values in binary bits
    using ?Sign-Magnitude and ? Twos Complement
  • Sign-Magnitude Twos Complement
  • 1810 100100102 111011102
  • 7010 110001102 101110102
  • 4210 001010102 001010102

15
Advantages of using 2s Comp.
  • No additional adjustments needed when performing
    arithmetic operations.
  • 12 12 00001100
  • 5 ? (-5) ? 11111011
  • 7 7 100000111
  • Overflow 7

16
Interpreting Negative Binaries
  • Sign-magnitude
  • Check the sign bit, combine the sign with the
    absolute value calculated from the rest of the
    bits.
  • Twos-Complement
  • Check the sign bit, if negative, perform the 2s
    complement to compute the absolute value. If
    positive, perform the regular binary to decimal
    conversion.

17
In Class Exercises
  • Find the value for the following sign-magnitude
    binary numbers
  • 10001001
  • 00011100
  • Find the values for the following twos
    complement binary numbers
  • 10001001
  • 00011100

18
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com