Lecture 5 Number System CSCS100 - Fall 2007 – Forman Christian College Asher Imtiaz Wajeeha Akram

“There are 10 kinds of people in the world: those who understand binary and those who don't.”

Ben Hammond

*Several of these slides have been adapted and modified from LUMS CS101 course (Dr Salim Tariq), VU CS101 slides (Dr. Altaf A. Khan) and Peter Norton’s supplementary material.

Goals

How Computers Represent Data

• To become familiar with the number system used by the microprocessors • Binary Numbers • Decimal to Binary Conversions

• Number systems • A manner of counting • Several different number systems exist

• Decimal number system • Used by humans to count • Contains ten distinct digits • Digits combine to make larger numbers

How Computers Represent Data

Number Systems

• Bits and bytes

• Decimal System

• Binary numbers are made of bits • Bit represents a switch • A byte is 8 bits • Byte represents one character

• Base 10

• Binary System • Base 2

• Octal System • Base 8

• Hexadecimal System • Base 16

Decimal Number System

Decimal Number System

• Base 10 system (Ten digits: 0, 1, 2, …, 9) • Counting process

• Expanded form

• Every digit goes through a cycle 0 Æ 9 • After a complete cycle of a lower significant digit (0 through 9) immediately higher digit is incremented by 1, while the lower significant digit is reset to 0. • 0Æ1Æ2Æ…9Æ10Æ11Æ…19Æ20Æ21 and so on

• 5429 = 5,000 + 400 + 20 + 9

OR • 5,429 = 5x103 + 4x102 + 2x101 + 9x100

Binary Number System

Binary Number System

• Base 2 system (2 digits; 0, 1) • Counting 0,1,10,11,100,101,110,111,1000,…

Expanded form

(0) 2 = (0)10

• (110010)2 = 1x25 + 1x24 + 1x21 = 32 + 16 + 2 = (50)10 • (1110)2 = 8+4+2=(14)10

(1) 2 = (1)10 (10) 2 = (2)10 (11) 2 = (3)10 (100) 2 = (4)10

Binary Number System 20 = (1)10 = (1) 2 21 = (2)10 = (10) 2 22 = (4)10 = (100) 2 23 = (8)10 = (1000) 2 M 2n =

= (100L 0) 2 N zeros

Decimal & Binary conversion • Convert (289)10 into binary • Convert (10111010)2 into decimal

Text Codes Table 5A.3

Maximum Number in n-bits • 2 bits, max number is 11 (3) • 3 bits, max number is 111 (7) • 8 bits, max number is 11111111 (255)

Lecture 5 Number System Ben Hammond Goals

Decimal Number System. • Base 10 system (Ten digits: 0, 1, 2, …, 9). • Counting process. • Every digit goes through a cycle 0 → 9. • After a complete cycle of a lower significant digit (0 through 9) immediately higher digit is incremented by 1, while the lower significant digit is reset to 0.

287KB Sizes 2 Downloads 262 Views

Recommend Documents

No documents