{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

LEC20080915

LEC20080915 - Introduction to Computer Programming CSC180...

This preview shows pages 1–4. Sign up to view the full content.

Introduction to Computer Programming September 15, 2008 CSC180 Fall 2008, University of Toronto

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Numeral systems Let b be the base of a number, and d be a digit of the number. Binary: b = 2 , d ∈ { 0 , 1 } Octal: b = 8 , d ∈ { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 } Decimal: b = 10 , d ∈ { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } Hexadecimal: b = 16 , d ∈ { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , A, B, C, D, E, F } Any base: b = B , B 2 , d ∈ { 0 , ..., B - 1 } CSC180 Fall 2008, University of Toronto 1
( d n d n - 1 · · · d 1 d 0 .f 1 f 2 · · · f m - 1 f m ) b = n i =0 d i · b i + m j =1 f j · b - j , where d i ∈ { 0 , ..., b - 1 } , 0 i n , and f j ∈ { 0 , ..., b - 1 } , 1 j m . The above formula can be used to convert a base- b number to a decimal number, where b can be any integer no less than 2. (12 . 34) 10 = 1 · 10 1 + 2 · 10 0 + 3 · 10 - 1 + 4 · 10 - 2 = 12 . 34 (1010 . 0101) 2 = 1 · 2 3 +0 · 2 2 +1 · 2 1 +0 · 2 0 +0 · 2 - 1 +1 · 2 - 2 +0 · 2 - 3 +1 · 2 - 4 = 10 . 3125 ( F 8) 16 = 15 · 16 1 + 8 · 16 0 = 248 Given a decimal number, how to convert it to a base- b number? Divide and conquer.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

LEC20080915 - Introduction to Computer Programming CSC180...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online