Hexadecimal Binary Made Easier
Quick Recap Two different systems – Computers use binary – Binary is hard to read What is ?? SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes
Middle Ground Need a system: – Easier to read – Converts easily to binary
Middle Ground Need a system: – Easier to read – Converts easily to binary Hexadecimal – base 16
Hexdecimal Base 16 – Each column is a power of 16: = 4096 * * * * 9 = = 8281 in decimal
13? How do we represent 13???
13? How do we represent 13??? – Use 0-9, A (10), B (11), C (12), D (13), E (14), F (15)
16 Values Each column needs 16 values 0-15 – Use 0-9, A (10), B (11), C (12), D (13), E (14), F (15) = 256 * * * 9 = = 489
Counting Equivalent values : = = C 16 DecimalBinaryHex DecimalBinaryHex A B C D E F DecimalBinaryHex
Conversion Among Bases The possibilities: Hexadecimal Decimal Binary
Hex & Binary Each hex digit = 16 possible values 4 binary digits = 16 possible values (2 4 ) 1 hex digit = 4 binary digits DecimalBinaryHex DecimalBinaryHex A B C D E F
Binary -> Hex Break binary value into groups of 4:
Binary -> Hex Break binary value into groups of 4: Replace each group with 1 hex digit BinaryHex A 1011B 1100C 1101D 1110E 1111F
Binary -> Hex Break binary value into groups of 4: D 1 6 Replace each group with 1 hex digit = 9D16 16 BinaryHexDecimal A B C D E F15
Hex -> Binary Replace each hex digit with 4 binary digits: Ex: F2 F F2 16 = BinaryHex A 1011B 1100C 1101D 1110E 1111F
Hex Decimal Use a table Digits 0-F A = 10 B = 11 C = 12 D = 13 E = 14 F = 15
Hex Decimal Use a table Digits 0-F A = 10 B = 11 C = 12 D = 13 E = 14 F = x x x 7 = = 455 1C7 16 =
Decimal Hex Division / Multiplication methods: Current Value QuotientRemainder 455 ÷ ÷ (C)C7 1 ÷ C7
Summary Hex is a bridge: – Easier for us – Still just binary for computers SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Hex160-9ABCDEF No, but better than binary No, but easily translates to binary
Colors Monitors make colors by mixing red/green/blue light: Typical 24 bits : 8 bits for each color – 2 8 = 256 possible values
Colors Hex Colors – Each color stored as – 8 bits – 2 hex digits
Web Colors Website colors often written in hex #RRGGBB – Two digits for red, two for green, two for blue Black#000000(0,0,0) White#FFFFFF(255,255,255) Red#FF0000(255,0,0) Lime#00FF00(0,255,0) Blue#0000FF(0,0,255) Yellow#FFFF00(255,255,0) Cyan / Aqua#00FFFF(0,255,255)