numbering systems chapter 1 department of computer science foundation year program umm alqura...

19
Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3 1435/1436

Upload: elfrieda-mcbride

Post on 14-Jan-2016

229 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering SystemsChapter 1

Department of Computer ScienceFoundation Year ProgramUmm Alqura University, Makkah

Computer Programming Skills

4800153-31435/1436

Page 2: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

The Objectives and the outcomes

The Objectives:

• To understand the principles of numbering systems

• To convert numbers from one base to another

• To be able to do arithmetic in binary and hexadecimal

The Outcomes:

• Understanding computer binary system• Converting numbers in different bases

Page 3: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Content

1. Numbering systems and computers

2. Principles of numbering systems

a. Binary

b. Hexadecimal

3. Converting numbers from one Base into another

a. Decimal to Binary or Hexadecimal

b. Binary to Decimal and Hexadecimal

c. Hexadecimal to Binary

d. Hexadecimal to Decimal

4. Arithmetic in BINARY

5. Exercises

Page 4: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• We humans use decimal numbers, or base 10• { 0, 1, 2 ,,,,,,,,,,, 8, 9 } : decimal or base 10

• Computers operate in binary and communicate to us in decimal• {0,1} : Binary or base 2

• A special program translates decimal into binary on input, and binary into decimal on output

• The hexadecimal numbering system is used only for the convenience of the programmer or computer scientist• {0,1 ,,,,,,,,,,,,,,,9, A,B,C,D,E,F } : Hexadecimal or

base 16• A =10 ,,,,,,,, F=15

Numbering systems and computers

Numbering Systems

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 5: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

• The hexadecimal numbering system is used only for the convenience of the programmer or computer scientist, or computer engineer when reading and reviewing the binary display of memory. Computers do not operate or process in hex.

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 6: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

• Numbering System Fundamentals• Example with the decimal number 124 or

(124)10

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 7: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

• Binary• Base-2• Binary use 2 digits {0,1}• Decimal use 10 digits {0,1,,,,,,,9}

• (10010)2

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 8: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

• Representing a Binary Number• Example with (1111100)2

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 9: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

• Hexadecimal• Base-16• {0,1 ,,,,,,,,,,,,,,,9, A,B,C,D,E,F } • A =10 ,,,,,,,, F=15

• (A01F)16

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Decimal Binary Hexadecimal

1 1 1

2 10 10

,,, ,,, ,,,

14 1110 E

15 1111 F

Page 10: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises Hexadecimal

Decimal

Binary

Page 11: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• Decimal to Binary

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 12: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• Decimal to Hexadecimal

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 13: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• Binary to Decimal

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 14: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• Hexadecimal to Binary

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises • Hexadecimal to Binary• We do the reverse of the previous

operation,

Page 15: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

• Hexadecimal to Decimal

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Page 16: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

• The essentials of decimal arithmetic operations have been drilled into us so that we do addition and subtraction almost by instinct.

Page 17: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

• Binary Addition

Page 18: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

• Binary Subtraction

Page 19: Numbering Systems Chapter 1 Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills 4800153-3

Numbering Systems

Numbering systems and computers

Principles of numbering systems

Converting numbers

Arithmetic in BINARY

Exercises

Decimal Binary Hexa-decimal

33 ??? ???

??? 1110101 ???

??? ??? 1AF