Download presentation
Presentation is loading. Please wait.
Published byNorah Mitchell Modified over 9 years ago
1
CSC 107 – Programming For Science
2
Positional Notation Used in nearly all modern numerical systems Right-to-left ordering of digits within larger number Expresses value using value of each digit (0, 1, 2, … 9) Value of position in which the digit is places e.g., 3, 13, 913, 0913, 10913, 810913 Numbers & arithmetic easy to understand Subtracting roman numerals is not for faint-of-heart
3
Positional Notation for 5862 2= 2 ones= 2 * 1 =2
4
Positional Notation for 5862 2= 2 ones= 2 * 1 =2 6= 6 tens= 6 * 10 =60
5
Positional Notation for 5862 2= 2 ones= 2 * 1 =2 6= 6 tens= 6 * 10 =60 8= 8 hundreds= 8 * 100 =800
6
Positional Notation for 5862 2= 2 ones= 2 * 1 =2 6= 6 tens= 6 * 10 =60 8= 8 hundreds= 8 * 100 =800 5= 5 thousands= 5 * 1000 =5000
7
Positional Notation for 5862 2= 2 ones= 2 * 1 =2 6= 6 tens= 6 * 10 =60 8= 8 hundreds= 8 * 100 =800 5= 5 thousands= 5 * 1000 =+ 5000 5862
8
Decimal Positional Notation Formal equation for a number d n...d 3 d 2 d 1 d 0 d 0 is digit in ones place, d 1 is in tens place, … d 0 * 10 0 d 1 * 10 1 d 2 * 10 2 d 3 * 10 3 … + d n * 10 n
9
Base-10 Positional Notation d0d0 2= 2 ones= 2 * 1 =2 d1d1 6= 6 tens= 6 * 10 =60 d2d2 8= 8 hundreds= 8 * 100 =800 d3d3 5= 5 thousands= 5 * 1000 =+ 5000 5862
10
Base-10 Positional Notation d0d0 2= 2 ones= 2 * 10 0 =2 d1d1 6= 6 tens= 6 * 10 1 =60 d2d2 8= 8 hundreds= 8 * 10 2 =800 d3d3 5= 5 thousands= 5 * 10 3 =+ 5000 5862
11
Base-10 Positional Notation d0d0 2= 2 ones= 2 * 10 0 =2 d1d1 6= 6 tens= 6 * 10 1 =60 d2d2 8= 8 hundreds= 8 * 10 2 =800 d3d3 5= 5 thousands= 5 * 10 3 =+ 5000 5862
12
Computer Number Systems Previous equation worked in decimal (base-10) Usual number system used in day-to-day life System requires representing 10 different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Computers always in one of two states Turned on, your PS3 can play Guitar Hero 3 Cell phones great paperweights when turned off Binary digits ( 0,1 ) only used by computers To use them, helps to know powers-of-two bases
13
Digits In Other Bases Binary (base-2) uses 2 digits: 0, 1 Octal (base-8) uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal (base-16) has 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F A 16 = 10 10 D 16 = 13 10 B 16 = 11 10 E 16 = 14 10 C 16 = 12 10 F 16 = 15 10
14
Positional Notation To convert d n... d 3 d 2 d 1 d 0 into decimal: From base-10 d 0 * 10 0 d 1 * 10 1 d 2 * 10 2 d 3 * 10 3 … + d n * 10 n
15
Positional Notation To convert d n... d 3 d 2 d 1 d 0 into decimal: From base-b d 0 * b 0 d 1 * b 1 d 2 * b 2 d 3 * b 3 … + d n * b n
16
Converting Binary to Decimal 101011 2 = d0d0 d1d1 d2d2 d3d3 d4d4 d5d5
17
Converting Binary to Decimal 101011 2 = d0d0 1* d1d1 1* d2d2 0* d3d3 1* d4d4 0* d5d5 1*
18
Converting Binary to Decimal 101011 2 = d0d0 1* 2 0 = d1d1 1* 2 1 = d2d2 0* 2 2 = d3d3 1* 2 3 = d4d4 0* 2 4 = d5d5 1* 2 5 =
19
Converting Hex to Decimal 27 16 = d0d0 d1d1 3F 16 = d0d0 d1d1
20
Converting Hex to Decimal 27 16 = d0d0 7 16 = 7 10 d1d1 2 16 = 2 10 3F 16 = d0d0 F 16 =15 10 d1d1 3 16 = 3 10
21
Converting Hex to Decimal 27 16 = d0d0 7 16 = 7 10 * 16 0 = d1d1 2 16 = 2 10 * 16 1 = 3F 16 = d0d0 F 16 =15 10 * 16 0 = d1d1 3 16 = 3 10 * 16 1 =
22
Positional Notation Review To convert d n... d 3 d 2 d 1 d 0 into decimal: From base-b d 0 * b 0 d 1 * b 1 d 2 * b 2 d 3 * b 3 … + d n * b n
23
Converting Decimal To Binary Converting from decimal to binary (base-2): While decimal number ≠ 0 Divide decimal number by 2 Move remainder to left end of answer Replace decimal number with quotient 34 10 =
24
Converting Decimal To Base-b More generally, convert from decimal to base-b: While decimal number ≠ 0 Divide decimal number by b Move remainder to left end of answer Replace decimal number with quotient 335 10 =
25
Your Turn Get in groups of 3 & work on following activity
26
For Next Lecture Read sections 3.1 – 3.7 in book for Friday What is required for a C program? Why is main so important? What are comments & how do we write them? Week #1 assignment posted to Angel 1 st problem deals with material from today All 3 problems will be due next Tuesday If problem takes more than 10 min., talk to me
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.