Number systems Converting numbers between binary octal decimal
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
Small numbers are easy to convert n But it helps to have a system for converting larger numbers to avoid errors. 12 10 = 11 00 5 10 -> 1 01 2 2 =1 21 0 C 16
DEMONSTRATE Converting from base 10 (decimal) example number = 42 to base 2 (binary) 1. 2. Write the powers of 2 in a row starting on the RIGHT side with a 1 Keep doubling (*2) until you get to something greater than your number (42) 64 32 16 8 4 2 1 This is too big Watch 1 0 1 42 10 2 -32 - 8 -2 ---- 10 2 0 3. Write a 1 underneath if that place value is used, 0 if not. subtract to find out what is left. 0 Read your answer from left to right The number in binary is 101010
DO TOGETHER Converting from base 10 (decimal) example number = 7053 to base 2 (binary) n write the powers of 2 in a row until you get to something > the number 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 Too big 1 1 13 5 1 -256 -128 - 8 -4 -1 ------- --- 5 1 0 1 7053 2957 909 397 141 -4096 -2048 - 512 ------- 2957 909 397 Do this together 0 1 1 141 1 13 0 0 0 1 the number in binary is 1101110001101
STUDENT’S TURN Do this one 15010 binary n 1 n 2 n 4 n 8 n 16 n 32 n 64 n 128 256 n Click to see each digit that is needed. Too big 1 0 0 1 1 0 The answer is: 10010110
To convert binary to decimal the number in binary is 10111001101 n Write the powers of 2 below each digit and only add the values with a 1 above them. 1 0 1 1 1 0 0 1 1 0 1 2 1024 512 256 128 64 32 16 8 4 2 1 1024 Watch + 256+128+64 + 8 + 4 + 1 = 1, 485 Start at the right and double each number
Your turn. Convert 1000100112 to decimal n 1 0 0 0 1 1 n 256 128 64 n 256 + 32 16 16 8 4 + 2 1 n 2+1 = 275 n …. And now, for more about number systems.
Part 2 n Number Systems
Quick review n What’s 41 in binary? 64 32 16 8 4 2 1 65 1 0 0 The answer is: 101001 1
Quick Review: binary to decimal 10011012 decimal n 64 + 8 + 4 + 1 n =77 n
An Introduction to Hexadecimal n n 16 digits Use letters when you run out of single digits 0123456789 ABCDEF SO… 1110 = ? 16 ¨ B 16 n 1510 = ? ¨ F 16 n 1610 = ? ¨ 1016
from base 10 to base 16 example number = 7053 (decimal to hexadecimal) n n n write the powers of 16 in a row until you get to one > the number divide the number by each power of 16 and write the answer and save the remainder 65, 536 4, 096 256 16 1 Too high 7053/4096 = 1 R 2957/256 = 11 R 141/16 = 8 R 13 13 ones n n n the numbers in hex are: ¨ n 123456789 ABCDEF So your number is (A=10…. F=15) 1 11 8 13 = 1 B 8 D 16 Watch
Do this one n 96210 hexadecimal 3 C 216 n This is 3*256 + C(10)*16 + 2 n
from hexadecimal (base 16) back to decimal 1 B 8 D Watch 16 n n n Write the number across a row. Write the powers of 16 below it. Multiply. Then add the products. 1 B 8 D 4096 256 16 1 =(1 X 4096)+ (11*256)+ (8*16)+(13*1) = 4096 + 2816 + 128 + 13 = 7053
Do this one n A 10 E 16 decimal n 41230
Octal n Base 8 n Uses 8 different digits n 0 1 2 3 4 5 6 7
from base 10 to base 8 (decimal to octal) example number = 7053 n write the powers of 8 in a row until you get to one > the number divide the number by each power of 8 Watch write the answer and save the remainder 32768 4096 512 64 8 1 n too high n n n n n 7053/4096 = 1 R 2957/512 = 5 R 397/64 = 6 R 13 13/8 = 1 R 5 = 5 ones so your number in octal is 156158
Do this one: n 94610 octal n 16628
from octal (base 8) back to decimal 156158 n n n n n write the number write the powers of 8 below it and multiply. then add the products. 1 5 6 1 5 Watch 4096 512 64 8 1 1 *4096 = 4096 5 * 512 = 2560 6 * 64 = 384 1* 8 = 8 5*1= 5 ¨ added together = 7053
Do this one n 20458 n 106110
0 Binary hex octal 1 10 11 n If you can count from 1 to 15 in binary you have it made 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
Binary to hexadecimal and hex to binary n n n n n Watch 4 binary digits correspond to 1 hexadecimal digit Start grouping digits on the RIGHT side 0000 0 To convert binary 1101011110 to hex 0001 1 0010 2 Binary Hexadecimal 0011 3 0100 4 11 0101 1110 0101 5 3 5 E 0110 6 0111 7 35 E 16 1000 8 1001 9 1010 A Write this down 1011 B Hex Binary the side of your 1100 C paper. 28 D 1 1101 D 1110 E 10 1000110100012 1111 F
Practice Hex Binary Hex n Convert E 5816 to Binary ¨ 111001011000 n Convert 110010110 to Hexadecimal ¨ 196
binary to octal and octal to binary n n n n n 3 binary digits correspond to 1 octal digit 000 0 001 1 Binary to octal 10110011 010 2 10 110 011 3 263 100 4 101 5 Octal to binary 110 6 451 100 101 001 111 7 100101001 Watch
Practice Octal Binary Octal n Convert 3078 to Binary ¨ 11000111 n Convert 110010110 to Octal ¨ 646
octal to hex and hex to octal. n Convert to binary, regroup and convert to other base. Octal to binary to hex 4518 100 101 001 100101001 1 0010 1001 12916 Watch
Practice Octal Hex n Convert 3078 to Hex ¨ 11 000 111 first in binary ¨ 11000111 ¨ 1100 0111 divide into groups of 4 ¨ 12 7 ¨ C 716
Practice Hex Octal n Convert 2 B 1 D 16 to Octal ¨ 10 1011 0001 1101 first in binary ¨ 10101100011101 ¨ 10 101 100 011 101 divide into groups of 3 ¨ 2 5 4 3 5 ¨ 254358
The End
- Slides: 29