W02-03_Numbers+Ch02CAO

# W02-03_Numbers+Ch02CAO - 03 Numbers Systems CSC 230...

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

03 Numbers Systems CSC 230 Department of Computer Science U i it f Vi t i University of Victoria 1

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

View Full Document
Integer Number Systems Decimal Base: 10 Digits: 0,1,2,3,4,5,6,7,8,9 Binary Octal Base: 2 Base: 8 Digits: 0,1 Digits: 0,1,2,3,4,5,6,7 Hexadecimal Base: 16 Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 2
Small Trivial Example 7423 in decimal = 3 + 3 + 3 x 10 0 + 20 + 400 + 2 x 10 + 4 x 100 + 2 x 10 1 + 4 x 10 2 + 7000 = 7 x 1000 7 x 10 3 3

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

View Full Document
Integer Number Systems: Base 10 - Decimal = n 1 n 2 1 0 Integer D D D D Positional Number Systems e.g. 7423 in decimal Base 10: ( ) × n 1 n 1 D 10 ( ) + × 0 0 D 10 ( ) + × n 2 n 2 D 10 ( ) + + × 1 1 D 10 ( ) ( ) 1 0 ( ) 3 ( ) 2 + × + × 2 10 3 10 = × 10 7423 7 10 + × 4 10 4
Integer Number Systems: Base 16 - Hexadecimal P iti l N b S t = n 1 n 2 1 0 Integer D D D D Positional Number Systems e.g. 8254 in hexadecimal Base 16: ( ) ( ) ( ) ( ) n 1 n 2 1 0 n 1 n 2 1 0 D 16 D 16 D 16 D 16 × + × + + × + × ( ) ( ) ( ) ( ) = × + × + × + × 3 2 1 0 16 8254 8 16 2 16 5 16 4 16 ( ) ( ) ( ) ( ) = × + × + × + × = 10 8 4096 2 256 5 16 4 1 33,364 5 NOTE: we have converted from hex to decimal!

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

View Full Document
Integer Number Systems: Base 2 - Binary Positional Number Systems = n 1 n 2 1 0 Integer D D D D e.g. 011011 in binary ( ) ( ) ( ) ( ) n 1 n 2 1 0 n 1 n 2 1 0 D 2 D 2 D 2 D 2 × + × + + × + × Base 2: ( ) ( ) ( ) ( ) ( ) ( ) = 0 110 11 2 = × + × + × + × + × + × 5 4 3 2 1 0 0 2 1 2 1 2 0 2 1 2 1 2 ( ) ( ) ( ) ( ) ( ) ( ) = × + × + × + × + × + × = 10 0 32 1 16 1 8 0 4 1 2 1 1 27 6 NOTE: we have converted from binary to decimal!
Weighted Positional Representation BASE: defines the range of values for digits (e.g. 0 – 9 for decimal; 0,1 for binary) GENERAL FORM AS AN n-BIT VECTOR: B = BASE n i i Integer Decimal Value d B = × 1 i = 0 d = DIGIT n i 1 i i m Decimal Value d B =− = × Include fractions . = × + × + × + × + × 2 1 0 1 2 10 145 52 1 10 4 10 5 10 5 10 2 10 Full example: 7 . . = + + + + 100 40 5 0 5 0 02

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

View Full Document
Memorize This Table! Binary Decimal Hexadecimal 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 10 A 1011 11 B 1100 12 C 1101 13 D 8 1110 14 E 1111 15 F
Summary 1: Conversion from any Base “B” to Decimal B to Decimal Î Use the polynomial expansion in Base “B” as shown Base “” gives the powers of the positional systemB Base gives the powers of the positional systemB ( ) ( ) ( ) ( ) 0 1 2 3 ( ) ( ) ( ) ( ) = × + × + × + × = × + × + × + × 16 7423 3 16 2 16 4 16 7 16 3 1 2 16 4 256 7 4096 = 10 29,731 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) = × + × + × + × + 0 1 2 3 2 4 5 6 7 11001011 1 2 1 2 0 2 1 2 9 × + × + × + × = 10 0 2 0 2 1 2 1 2 203

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

View Full Document
Conversion from One Base to Another D i l t B “B” f iti i t Decimal to Base “B” for positive integers 1. Repeated division by base “B” 2. Collect remainders 3. Form result from right to left Example 1: from decimal to binary 35 10 = ??? 2 35/2 = 17 + remainder 1 35/2 17 + remainder 1 17/2 = 8 + remainder 1 8/2 = 4 + remainder 0 4/2 = 2 + remainder 0 2/2 = 1 + remainder 0 10 1/2 = 0 + remainder 1 answer: 100011 2
Conversion from One Base to Another D i l t B “B” f iti i t Decimal to Base “B” for positive integers 1. Repeated division by base “B” 2. Collect remainders 3. Form result from right to left Example 2: from decimal to hexadecimal 35 10 = ???

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 ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern