Binary Decimal and Hexadecimal System You Tube Video
Binary, Decimal and Hexadecimal System
You Tube Video on Binary Conversion • https: //www. youtube. com/watch? v=_JG_QGDOOFM&list=PLr. CHc. VNf. ULb. GKkh. JSgfqvqma. FAZvf. Hes&index=1
Binary, Decimal, Hexadecimal? • Binary, decimal and hexadecimal are mathematical representations of how a computer understands information. • We input information in decimal form (number of bytes) or hexadecimal form (used also in a colour wheel) and the computer converts it into binary information. • We are quite familiar with decimal form, we use it everyday.
Decimal Form • The decimal system is the base-10 system that we use every day. • Let’s use the number 6357. We have a 6 in the thousands place holder, a 3 in the hundreds place holder, a 5 in the tens place holder and a 7 in the ones place holder. Thousands Hundreds Tens Ones 6 3 5 7 10^3 (1000) 10^2 (100) 10^1 (10) 10^0 (1) • In each place holder we can have a numerical values between 0 and 9. • In our example, it looks like this mathematically (6 * 1000) + (3 * 100) + (5 * 10) + (7 * 1) = 6000 + 300 + 50 + 7 = 6357
Decimals for humans, Binary for computers • Decimals are calculated using the base power of 10, why would that be? • Let me ask you this, how many fingers do we have? • Ahhhh HA, there is our answer. • But a computer only has two ”fingers”, on off or as we know it to be 1’s and 0’s • This is called binary because the prefex bi = two, and as such binary code is a bunch of 1’s and 0’s. • Can you guess what the base power is for binary code? • Yup it is 2!!!!!
Binary System • Recall that one (1) byte is equal to eight (8) bits. • As such, we have 8 place holders filled with a 1 or a 0, with each place holder having a base of 2. 1 0 1 1 1 0 0 1 2^7 = 128 2^6 =64 2^5 =32 2^4 =16 2^3 =8 2^2 =4 2^1 =2 2^0 =1
Convert Binary to Decimal Binary 0 0 1 1 1 0 Binary Powers 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 Decimal Values 128 64 32 16 8 4 2 1 Actual Values 0 0 32 16 8 0 2 0 Sum 32+16+8+2 Total 58
Convert the following Binary Code to Decimal Binary Code 11001010 00100100 11110000 1111 0101 11011110 Decimal Values 202 36 240 255 85 222
Convert Decimal into Binary • Now to convert decimal into binary you have to: 1. Start at the furthers point on the right and work to the left. Write the decimal number that you start with. 2. Take the decimal number, divide it by two and ignore the remainder and write it down to the LEFT of the first number. 3. Take this new whole number and divide it in half and ignore the remainder. Continue this pattern until you get to the number 1 4. Then below the whole numbers, write a 1 for odd numbers and a 0 for even numbers. 5. If you only have 5 places filled write enough 0’s to the left to complete your set of 8 placeholders
Convert Decimal into Binary Decimal Value of 36 1 2 4 9 18 36 Binary Code (Setting it up) 1 0 0 Final Binary Code 0 0 1 0 0 Decimal Value of 237 1 3 7 14 29 59 118 237 Binary Code (Setting it up) 1 1 1 0 1 Final Binary Code 1 1 1 0 1
Convert the following to Binary Code Decimal Value Final Binary Code 245 11110101 36 00100100 165 10100101 99 568 01100011 0000001000 111000 OR 00000010 00111000
Hexadecimal • Although not a problem internally, long binary number can be a problem to display in some situations. A common practice to solve this problem is to use hexadecimal to represent Binary numbers more compactly externally. • The hexadecimal system is base 16. Therefore, it requires 16 different symbols. The values 0 through 9 are used, along with the letters A through F, which represent the decimal values 10 through 15. 0123456789 A B C D E F 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Binary, Decimal, Hexadecimal 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 1110 14 E 1111 15 F
Couple of Hex, Decimal and Binary Hex Decimal Binary 10 16 10000 F 0 240 11110000 FF 255 1111
Convert Decimal to Hexadecimal • How to convert Decimal to Hexadecimal 1. Divide the decimal number by 16. Treat the division as an integer division. 2. Write down the remainder, multiply it by 16 and this value is the hexadecimal value. 3. Divide the result again by 16. Treat the division as an integer division. 4. Repeat step 2 and 3 until result is 0. 5. The hex value is the digit sequence of the remainders from the last to first.
Decimal to Hexadecimal • Convert 1128 into Hexadecimal Division Result Remainder * 16 Hexadecimal Value 1128 /16 70. 5 (. 5) * 16 8 70 / 16 4. 375 (. 375) * 16 6 4 / 16 0. 25 (. 25) * 16 4 • Hexadecimal answer of decimal 1128 is 468 • Convert 222 into Hexadecimal Division Result Remainder * 16 Hexadecimal Value 222/16 13. 875 (. 875) * 16 14 = E 13 / 16 0. 8125 (. 8125) * 16 13 = D • Hexadecimal answer of decimal 222 = DE
Decimal to Hexadecimal Examples Decimal 257 188 100 590 Hexadecimal 101 BC 64 24 E
Hexadecimal to Decimal Hexadecimal 7 D 2 16^1 16^0 Decimal Calculation 7*16^2 13*16^1 2*16^0 Decimal Values 1792 208 2 Hexadecimal Powers 16^6 16^5 16^4 16^3 Sum 1792+208+2 Total 2002
Hexadecimal to Decimal • Convert the following Hexadecimal’s into decimal’s. Hexadecimal 46 36 A 91 D FB Decimal 70 874 2333 251
You and I in Hexadecimal, Decimal and Binary • You & I, in Hex: • 59 6 F 75 20 26 20 49 2 C • You & I, in decimal: • 89 111 117 32 38 32 73 44 • You & I, in binary: • 01011001 01101111 01110101 00100000 00100110 00100000 01001001 00101100
Some interesting facts about what these various-sized bytes can store: 1 bit: a binary decision 1 byte (b): a character 5 Megabytes (Mb): The complete works of Shakespeare 2 Gigabytes (Gb): 20 meters of shelved books 10 Terabytes (Tb): The printed collection of the Canadian Library of Parliament • 200 Petabytes (Pb): All printed material in the whole word. • 5 Exabytes: All words ever spoken by human beings • • •
Useful Websites on converting between Hex, Deci and Binary • Websites that help break down the different codes • http: //www. mathsisfun. com/binary-decimalhexadecimal. html • Computer programs that will convert the information for you • http: //www. binaryhexconverter. com/
- Slides: 22