numbering systems chapter 1 department of computer science foundation year program umm alqura...
TRANSCRIPT
Numbering SystemsChapter 1
Department of Computer ScienceFoundation Year ProgramUmm Alqura University, Makkah
Computer Programming Skills
4800153-31435/1436
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
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
• 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
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
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
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
Numbering Systems
• Representing a Binary Number• Example with (1111100)2
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
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
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises Hexadecimal
Decimal
Binary
• Decimal to Binary
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
• Decimal to Hexadecimal
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
• Binary to Decimal
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
• 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,
• Hexadecimal to Decimal
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
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.
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
• Binary Addition
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
• Binary Subtraction
Numbering Systems
Numbering systems and computers
Principles of numbering systems
Converting numbers
Arithmetic in BINARY
Exercises
Decimal Binary Hexa-decimal
33 ??? ???
??? 1110101 ???
??? ??? 1AF