Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objective 1.02 Understand Numbering Systems

Similar presentations


Presentation on theme: "Objective 1.02 Understand Numbering Systems"— Presentation transcript:

1 Objective 1.02 Understand Numbering Systems
Computer Programming I

2 Number Systems Number systems we will talk about: Decimal (Base10)
Binary (Base2) Hexadecimal (Base16) Computer Programming I 2/19/2019

3 Decimal The number system we use in math and in life.
Base 10: ten one digit numbers: 0,1,2,3,4,5,6,7,8,9 After 9 comes 10 (the first two digit number) of course. 102= 100 Base squared = 100 2 3 7 1 6 8 9 4 5 Computer Programming I 2/19/2019

4 Decimal 4 What can we say about the decimal system? It is our day to day number system… The Decimal system has 10 digits; values are from 0 to 9.

5 Binary Binary is Base 2 2 one digit numbers
0 and 1 For example: Base 10 of 4 = Binary or 100 102=100 – works in binary too! 2 squared = 4 Computer Programming I 2/19/2019

6 Machine Language OOOO OOOO 128 64 32 16 8 4 2 1
Binary or Base2: Only contains 2 types of digits; 1 or 0. The power of 2. Each digit from the right to the left is increased by power of 2. Each one (1) digit has a value representing on and each zero (0) digit do not hold a value representing off. OOOO OOOO Ex: = The right most digit (1) = 1 (20) The two middle digits are 0 therefore have no value. The left most digit (1) = 8 (23 or 2x2x2). The other digits have no value. The total value of all numbers would = 9. ( ) ex:  = 15 in decimal amount  = 255

7 Why Binary? Computers operate on a series on electric impulses.
If the current is flowing the circuit is complete (1), otherwise the current is off (0) Write down the powers of 2 from 27 128 26 64 25 32 24 16 23 8 22 4 21 2 20 1 Computer Programming I 2/19/2019

8 Powers of 2 Remember from math the powers of 2:
1, 2, 4, 8, 16, 32, 64, 128 (first 8) Remember any number to the zero power is 1 and any number to the 1 power is that number. So if Decimal 4= 100 in binary, what does decimal 5 equal in binary? Computer Programming I 2/19/2019

9 Powers of 2 Remember from math the powers of 2:
1, 2, 4, 8, 16, 32, 64, 128 (first 8) Remember any number to the zero power is 1 and any number of the 1 power is that number. So if Decimal 4= 100 in binary, what does decimal 5 equal in binary? A: 101 1 1 22 4 21 2 20 1 Computer Programming I 2/19/2019

10 The 1’s So let’s go beyond our basic example.
Remember the most right digit has the least significant value and the most left digit has the most significant value. What is in Decimal? That would be So… would be 256, right? 1 1 1 1 1 1 1 1 27 128 26 64 25 32 24 16 23 8 22 4 21 2 20 1 1 28 256 27 128 26 64 25 32 24 16 23 8 22 4 21 2 20 1 Computer Programming I 2/19/2019

11 Let’s Try This… On your paper draw 8 columns
Above each column label a power of 2, starting at 128 in the first (left most) column. Finish with 1 in the last (right most) column. 27 128 26 64 25 32 24 16 23 8 22 4 21 2 20 1 Computer Programming I 2/19/2019

12 Example Binary Figure out the following numbers in binary… Decimal 56
100 198 64 18 84 231 27 128 26 64 25 32 24 16 23 8 22 4 21 2 20 1 Computer Programming I 2/19/2019

13 Example Binary Answers
Figure out the following numbers in binary: Dec Binary (Answer) 56  100 198 64  18  10010 84  231 Computer Programming I 2/19/2019

14 Hexadecimal Hex is Base 16 There are fifteen one digit numbers:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F What comes after F? Remember our rule: 102=100 (162=256 in decimal) This works in Hex as it does for ANY number system. Computer Programming I 2/19/2019

15 Hexadecimal 15 Contains 16 digits starting with 0-9 & A-F containing the values from 0 – 15. Hex Dec Hex Dec -Hex 20-2F and so on… 0 = = Each digit carries a value of 16. 1 = = Hex = 6 + Decimal = 10 (Hexadecimal =16) 2 = = Hexadecimal is only 4 bits (binary value) 3 = = ex: 1111 = 15 in decimal “F” in Hex value 4 = = 20 -Another ex: = 9C in Hex and 5 = = in Decimal value. 6 = = 22 7 = = 23 8 = = 24 9 = = Remember! Hex is only 4 bits long and its A = A = 26 highest value is F in Hex or B = B = in decimal or 1111 in binary. C = C = 28 D = D = 29 Mainframe computers use Hexadecimal to E = E = 30 utilize less disk space. F = F = 31

16 Hexadecimal Conversion
Hex 9F to binary F Hex 9F to Decimal 9 F (16 * 9) + (1 * 15) = 159 in Decimal Add the values… 9F Base 16 = Base 2 23 8 22 4 21 2 20 1 23 8 22 4 21 2 20 1 9F Base 16 = 159 Base 10 161 16 160 16 Computer Programming I

17 Hexadecimal Think if you had 3 hands. You would have 15 fingers right?
That is what hex has! So after 9 comes A (10), B (11), C (12), D (13), E (14) and F (15) Let try our example again in Hex. Computer Programming I 2/19/2019

18 Another Conversion to Hexadecimal
Figure out the following Decimal numbers to Hex: Decimal 56 100 198 64 18 128 231 3 8 162 256 161 16 160 1 Ask “How many of ‘256’ can come out of 56 (our decimal number)? 0 Ask “How many of ‘16’ can come out of 56? (3 * 16 = 48 with 8 left over) Put the 3 in the 16’s spot Ask “How many of ‘1’ can come out of 8 (the left over)? with 0 left over Computer Programming I 2/19/2019

19 Example Hex Answers Figure out the following Decimal numbers to Hex: Dec Hex 56  38 100 64 198 C6 64  40 18  12 128 80 256 100 Computer Programming I 2/19/2019

20 Conclusion In this lesson we learned about number systems used in Programming. Decimal Binary Hexadecimal Computer Programming I 2/19/2019

21 For More Information 24


Download ppt "Objective 1.02 Understand Numbering Systems"

Similar presentations


Ads by Google