• Save
Lecture 2 itc
Upcoming SlideShare
Loading in...5
×
 

Lecture 2 itc

on

  • 465 views

 

Statistics

Views

Total Views
465
Views on SlideShare
465
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Lecture 2 itc Lecture 2 itc Presentation Transcript

    • Lecture 2: Decimal, Binary, Octal and Hexadecimal Numbers Aneel Ahmed
    • Convert from Decimal to Binary
      • (26) 10 = 16 + 8 + 2 = (11010) 2
      • (100) 10 = 64 + 32 + 4 = (1100100) 2
      • (15) 10 = 8 + 4 + 2 + 1 = (1111) 2
      • (79) 10 = 64 + 8 + 4 + 2 + 1 = (1001111) 2
    • Convert from Binary to Octal
      • (1000) 2 = (10) 8
      • (1001010111) 2 = (1127) 8
      • (111111) 2 = (77) 8 = (63) 10
      • (100111011101010110) 2 = (473526) 8
    • Convert from Octal to Binary
      • (777) 8 = (111 111 111) 2
      • (123) 8 = (001 010 011) 2
      • (123) 8 = (001 010 011) 2
      • (20) 8 = (010 000) 2 = (16) 10
      • (100) 8 = (001 000 000) 2 = (64) 10
    • Convert from Binary to Hex
      • (1000) 2 = (8) 16
      • (1010) 2 = (A) 16
      • (1011) 2 = (B) 16
      • (1100) 2 = (C) 16
      • (1101) 2 = (D) 16
      • (1110) 2 = (E) 16
      • (1111) 2 = (F) 16
      • (100010110) 2 = (116) 16
      • (1001 0100 1111 1011 1101) 2 = (94FBD) 16
    • Convert from Hex to Binary
      • (ABCDEF) 16 = (101010111100110111101111) 2
      • (9A) 16 = (10011010) 2
      • (7F) 16 = (01111111) 2
      • (10) 16 = (00010000) 2 = (16) 10
    • Handling Negatives
      • These methods work as long as your values are zero or positive. What about if your values can be negative? In human notation, we just write a "-" in front, to indicate the sign of the number. (We do sometimes also write a "+" for positives, although usually we just assume it).
      • The same trick can be used to write negatives in binary, except now instead of writing "+" or "-" for the sign, we can write "0" to mean "positive" and "1" to mean "negative". You can then write the rest of the value as the absolute value of your number.
      • This is called signed magnitude representation
    • Negative Binary Numbers
      • (-12) 10 = (1 1100) 2 where 1100 is the value of twelve in binary and 1 represents whether it is negative or positive (0 = zero/positive, 1 = negative).
      • By contrast, positive 12 would be written 01100. This basically just mirrors how we write numbers on paper.
      • Question: What does #b(110011) represent?
      • Answer: It depends: Is this a regular unsigned binary value? Or is it signed magnitude? Unsigned: 32 + 16 + 2 + 1 = 51 Signed Mag: (negative) 16 + 2 + 1 = -19
      • Key idea: when interpreting a binary number, in addition to knowing the bits, you also have to know what representation to interpret it against.
    • Binary Addition
      • 23 + 48 = 71
      • 0 + 0 = 0
      • 0 + 1 = 1
      • 1 + 1 = 10
      • Try a few examples of binary addition:
        • 111 + 110
        • 101 + 111
        • 111 + 111
    • Binary Subtraction
      • 0 – 0 = 0
      • 1 – 0 = 1
      • 1 – 1 = 0
      • 0 – 1 = 1
      • Try: 10000 - 10
    • One’s Complement
      • In one's complement, positive numbers are represented as usual in regular binary.
      • However, negative numbers are represented differently. To negate a number, replace all zeros with ones, and ones with zeros - flip the bits.