Fundamentals of Programming Lecture 2 Hamed Rasifard Outline - - PowerPoint PPT Presentation

fundamentals of programming
SMART_READER_LITE
LIVE PREVIEW

Fundamentals of Programming Lecture 2 Hamed Rasifard Outline - - PowerPoint PPT Presentation

Fundamentals of Programming Lecture 2 Hamed Rasifard Outline Numerical Systems Converting Numbers Summation and Subtraction of Binary Numbers Numerical Systems Binary (base 2) Octal (base 8) Decimal (Base 10)


slide-1
SLIDE 1

Fundamentals of Programming

Lecture 2 Hamed Rasifard

slide-2
SLIDE 2

Outline

  • Numerical Systems
  • Converting Numbers
  • Summation and Subtraction of Binary

Numbers

slide-3
SLIDE 3

Numerical Systems

  • Binary (base 2)
  • Octal (base 8)
  • Decimal (Base 10)
  • Hexadecimal (Base 16)
slide-4
SLIDE 4

Digits

Binary Octal Decimal Hexadecimal

1 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 9 9 A B C D E F

slide-5
SLIDE 5

Numbers & Notation

  • Numbers:

Binary: 101, 1100, 1001, 10011 Decimal: 101, 676, 245, 1470 Octal: 101, 345, 777 Hexadecimal:101, 234, 547E, A45CF

  • Notation

Mention base: (101)2, (101)10, (345)8

slide-6
SLIDE 6

Positional Value

  • (747)10 = (7*100 + 4*10 + 7*1)10
  • (101)2 = (1*100 + 0*10 + 1*1)2
  • (457)8 = (4*100 + 5*10 + 7*1)8
slide-7
SLIDE 7

Bits & Bytes

  • Memories consists of bits
  • Each bit could keep 0 or 1
  • Every 8 bits make a Byte
slide-8
SLIDE 8

Converting Binary Numbers to Octal and Hexadecimal Numbers

  • Binary to Octal: Separate each 3 Bits

and rewrite their equivalents

(101011)2 (53)8

  • Binary to Hexadecimal: Separate each 4

Bits and rewrite their equivalents

(101011)2 (2B)16

slide-9
SLIDE 9
  • Octal to Binary: write 3 binary digits for

every octal digits

(653)8 (110101011)2

  • Hexadecimal to Binary: write 4 binary

digits for every octal digits

(FAD5)16 (1111101011010101)2

Converting Octal and Hexadecimal Numbers to Binary Numbers

slide-10
SLIDE 10
  • Express base positional values in

decimal

(1*100 + 0*10 + 1*1)2=(1*22 + 0*21 + 1*20)10 (1*100 + 0*10 + 1*1)8=(1*82 + 0*81 + 1*80)10 (1*100 + 0*10 + 1*1)16=(1*162 + 0*161 + 1*160)10

Converting Octal and Hexadecimal and Binary to Decimal

slide-11
SLIDE 11
  • write the positional values of the

columns right to left

  • Find a column whose positional value

is greater than the decimal number

  • From the leftmost column to the right

divide number to positional values

Converting Decimal to Octal and Hexadecimal and Binary

slide-12
SLIDE 12

Represent Negative Numbers in Computer Systems

  • Bit-Sign
  • One’s complement notation
  • Two’s complement notation
slide-13
SLIDE 13

Summation and Subtraction in Computer Systems

  • Summation: Just ordinary add(consider
  • verflow)
  • Subtraction: Add first number to two’s

complement of second number