LECTURE 8: COMPUTERS AS STORAGE PHY 107 – Programming For Science
Jan 17, 2016
LECTURE 8:COMPUTERS AS STORAGE
PHY 107 – Programming For Science
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
Positional Notation for 58622 = 2 ones = 2 * 1 = 2
Positional Notation for 58622 = 2 ones = 2 * 1 = 2
6 = 6 tens = 6 * 10 = 60
Positional Notation for 58622 = 2 ones = 2 * 1 = 2
6 = 6 tens = 6 * 10 = 60
8 = 8 hundreds = 8 * 100 = 800
Positional Notation for 58622 = 2 ones = 2 * 1 = 2
6 = 6 tens = 6 * 10 = 60
8 = 8 hundreds = 8 * 100 = 800
5 = 5 thousands = 5 * 1000 = 5000
Positional Notation for 58622 = 2 ones = 2 * 1 = 2
6 = 6 tens = 6 * 10 = 60
8 = 8 hundreds = 8 * 100 = 800
5 = 5 thousands = 5 * 1000 = + 5000
5862
Decimal Positional Notation
Formal equation for a number dn...d3d2d1d0 d0 is digit in ones place, d1 is in tens place,
…d0 * 100
d1 * 101
d2 * 102
d3 * 103
…
+ dn * 10n
Base-10 Positional Notation
d0 2 = 2 ones = 2 * 1 = 2
d1 6 = 6 tens = 6 * 10 = 60
d2 8 = 8 hundreds = 8 * 100 = 800
d3 5 = 5 thousands = 5 * 1000 = + 5000
5862
Base-10 Positional Notation
d0 2 = 2 ones = 2 * 100 = 2
d1 6 = 6 tens = 6 * 101 = 60
d2 8 = 8 hundreds = 8 * 102 = 800
d3 5 = 5 thousands = 5 * 103 = + 5000
5862
Base-10 Positional Notation
d0 2 = 2 ones = 2 * 100 = 2
d1 6 = 6 tens = 6 * 101 = 60
d2 8 = 8 hundreds = 8 * 102 = 800
d3 5 = 5 thousands = 5 * 103 = + 5000
5862
Base-10 Positional Notation
d0 2 = 2 ones = 2 * 100 = 2
d1 6 = 6 tens = 6 * 101 = 60
d2 8 = 8 hundreds = 8 * 102 = 800
d3 5 = 5 thousands = 5 * 103 = + 5000
5862
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 PS4 can play Bloodborne 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
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
A16 = 1010 D16 = 1310
B16 = 1110 E16 = 1410
C16 = 1210 F16 = 1510
Positional Notation
To convert dn...d3d2d1d0 into decimal:
From base-10d0 * 100
d1 * 101
d2 * 102
d3 * 103
…
+ dn * 10n
Positional Notation
To convert dn...d3d2d1d0 into decimal:
From base-bd0 * b0
d1 * b1
d2 * b2
d3 * b3
…
+ dn * bn
Converting Binary to Decimal1010112 = d0
d1
d2
d3
d4
d5
Converting Binary to Decimal1010112 = d0 1 *
d1 1 *
d2 0 *
d3 1 *
d4 0 *
d5 1 *
Converting Binary to Decimal1010112 = d0 1 * 20 =
d1 1 * 21 =
d2 0 * 22 =
d3 1 * 23 =
d4 0 * 24 =
d5 1 * 25 =
Converting Hex to Decimal
2716 = d0
d1
3F16 = d0
d1
Converting Hex to Decimal
2716 = d0 716= 710
d1 216= 210
3F16 = d0 F16=1510
d1 316= 310
Converting Hex to Decimal
2716 = d0 716= 710 * 160 =
d1 216= 210 * 161 =
3F16 = d0 F16=1510 * 160 =
d1 316= 310 * 161 =
Positional Notation Review
To convert dn...d3d2d1d0 into decimal:
From base-bd0 * b0
d1 * b1
d2 * b2
d3 * b3
…
+ dn * bn
Converting Decimal To Binary Converting from decimal to binary
(base-2):While decimal number ≠ 0
Divide decimal number by 2Move remainder to left end of
answerReplace decimal number with
quotient
3410 =
Converting Decimal To Base-b More generally, convert from decimal
to base-b: While decimal number ≠ 0
Divide decimal number by bMove remainder to left end of
answerReplace decimal number with
quotient
33510 = 16
Your Turn
Get in groups & work on following activity
For Next Lecture
Read pages 91 – 98 for Monday What is the boolean data type? How do the boolean operations work? What happens when we execute an if
statement
Week #3 weekly assignment due Tuesday Problems available via D2L If problem takes more than 10 minutes,
TALK TO ME!