number systems cit 1121. network math
TRANSCRIPT
Base 10 number system – The Math
• The decimal number system: based on powers of 10. • Each column position of a value, from right to left, is multiplied by the
number 10, which is the base number, raised to a power, which is the exponent.
• The power that 10 is raised to depends on its position to the left of the decimal point.
• 2134 = (2x103) + (1x102) + (3x101) + (4x100)
Base 10 (Decimal) Number System
Digits (10): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Number of:
104 103 102 101 100
10,000’s 1,000’s 100’s 10’s 1’s
1,309 1 3 0 9
99 9 9
100 1 0 0
1. All digits start with 0
2. A Base-n number system has n number of digits:– Decimal: Base-10 has 10 digits– Binary: Base-2 has 2 digits– Hexadecimal: Base-16 has 16 digits
3. The first column is always the number of 1’s
• Each of the following columns is n times the previous column (n = Base-n)– Base 10: 10,000 1,000 100 10 1– Base 2: 16 8 4 2 1 – Base 16: 65,536 4,096 256 16 1
Number System Rules
Base 2 number system – The Math
• 101102 = (1 x 24 = 16) + (0 x 23 = 0) + (1 x 22 = 4) + (1 x 21
= 2) + (0 x 20 = 0) = 22 (16 + 0 + 4 + 2 + 0)
Digits (2): 0, 1
Number of:
27 ___ ___ ___ 23 22 21 20
128’s 8’s 4’s 2’s 1’s
Dec.
2 1 0
10 1 0 1 0
17
70
130
255
Base 2 (Binary) Number System
Digits (2): 0, 1
Number of:
27 26 25 24 23 22 21 20
128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s
Dec.
2 1 0
10 1 0 1 0
17 1 0 0 0 1
70 1 0 0 0 1 1 0
130 1 0 0 0 0 0 1 0
255 1 1 1 1 1 1 1 1
Base 2 (Binary) Number System
Digits (2): 0, 1
Number of:
27 26 25 24 23 22 21 20
128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s
Dec.
1 0 0 0 1 1 0
1 0 1 0 0 0
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
172
192
Converting between Decimal and Binary
Digits (2): 0, 1
Number of:
27 26 25 24 23 22 21 20
128’s 64’s 32’s 16’s 8’s 4’s 2’s 1’s
Dec.
70 1 0 0 0 1 1 0
40 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0
128 1 0 0 0 0 0 0 0
172 1 0 1 0 1 1 0 0
192 1 1 0 0 0 0 0 0
Converting between Decimal and Binary
Computers do Binary
0 1• If this is new to you, see me after class.• Bits have two values: OFF and ON• The Binary number system (Base-2) can represent OFF
and ON very well since it has two values, 0 and 1– 0 = OFF– 1 = ON
• Understanding Binary to Decimal conversion is critical in networking.
• Although we use decimal numbers in networking to display information such as IP addresses (LATER), they are transmitted as OFF’s and ON’s that we represent in binary.
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Decimal Hexadecimal Decimal Hexadecimal
0 0 8 8
1 1 9 9
2 2 10 A
3 3 11 B
4 4 12 C
5 5 13 D
6 6 14 E
7 7 15 F
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
___ ___ 161 160
Dec. 16’s 1’s
8
9
10
15
16
17
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
163 162 161 160
Dec. 4,096’s 256’s 16’s 1’s
8 8
9 9
10 A
15 F
16 1 0
17 1 1
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
163 162 161 160
Dec. 4,096’s 256’s 16’s 1’s
25
66
100
254
255
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
163 162 161 160
Dec. 4,096’s 256’s 16’s 1’s
25 1 9
66 4 2
100 6 4
254 F E
255 F F
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
163 162 161 160
Dec. 4,096’s 256’s 16’s 1’s
1 AC
2 0 3
Base 16 (Hexadecimal) Number System
Digits (16):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Number of:
163 162 161 160
Dec. 4,096’s 256’s 16’s 1’s
428 1 AC
515 2 0 3
Base 16 (Hexadecimal) Number System
Why Hexadecimal?
• Hexadecimal is perfect for matching 4 bits. • 16 Hex values which means 16 4 bit possibilities.• 4 bits can be represented by 1 Hex value• 8 bits (1 byte or octet) can be represented by 2 Hex values
Dec. Hex. Binary Dec. Hex. Binary 8421 8421 0 0 0000 8 1 9 2 10 3 11 4 12 5 13 6 14 7 15
Why Hexadecimal?
Dec. Hex. Binary Dec. Hex. Binary
8421 8421
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Here are 48 bits being transmitted:
000000000010000011100000011010110001011101100010
Break them up into 4 bit chunks:
0000 0000 0010 0000 1110 0000 0110 1011 0001 0111 0110 0010
0 0 2
Convert each 4 bits to Hexadecimal:
Why Hex?
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Here are 48 bits being transmitted:
000000000010000011100000011010110001011101100010
Break them up into 4 bit chunks:
0000 0000 0010 0000 1110 0000 0110 1011 0001 0111 0110 0010
0 0 2 0 E 0 6 B 1 7 6 2
Convert each 4 bits to Hexadecimal:
Why Hex?
Why Hex?
Hexadecimal is an easy way to represent a string of bits.
Here are 48 bits being transmitted:
0000000000100000011010110001011101100010
Break them up into 4 bit chunks:
0000 0000 0010 0000 1110 0000 0110 1011 0001 0111 0110 0010
Convert each 4 bits to Hexadecimal:
0 0 2 0 E 0 6 B 1 7 6 2
Converting Decimal, Hex, and Binary
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Dec. Hex Binary Dec. Hex Binary Dec. Hex Binary
0 0010 10
F 1110 12
A 0000 5
C 0010 1000
Converting Decimal, Hex, and Binary
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Dec. Hex Binary Dec. Hex Binary Dec. Hex Binary
0 0 0000 2 2 0010 10 A 1010
15 F 1111 14 E 1110 12 C 1100
10 A 1010 0 0 0000 5 5 0101
12 C 1100 2 2 0010 8 8 1000
Converting Hex, and Binary
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Hex Binary Hex Binary Hex Binary
12 0001 0010 3C 99
AB 1A 00
02 B4 7D
0111 0111 1000 1111 1111 1111
0000 0010 1100 1001 0101 1100
Converting Hex and Binary (Bytes)
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
Hex Binary Hex Binary Hex Binary
12 0001 0010 3C 0011 1100 99 1001 1001
AB 1010 1011 1A 0001 1010 00 0000 0000
02 0000 0010 B4 1011 0100 7D 0111 1101
77 0111 0111 8F 1000 1111 FF 1111 1111
02 0000 0010 C9 1100 1001 5C 0101 1100
RGB Colors and Binary Representation
• A monitors screen is divided into a grid of small unit called picture elements or pixels. (See reading from Chapter 1).
• The more pixels per inch the better the resolution, the sharper the image.
• All colors on the screen are a combination of red, green and blue (RGB), just at various intensities.
• Each Color intensity of red, green and blue represented as a quantity from 0 through 255.
• Higher the number the more intense the color.
• Black has no intensity or no color and has the value (0, 0, 0)
• White is full intensity and has the value (255, 255, 255)
• Between these extremes is a whole range of colors and intensities.
• Grey is somewhere in between (127, 127, 127)
RGB Colors and Binary Representation
• You can use your favorite program that allows you to choose colors to view these various red, green and blue values.
www.december.com
• For those of you interested in Web Design and Digital Media, you will work with colors based on hexadecimal code, hue, other codes, or shades.
• http://www.december.com/html/spec/color.html
Color Codes
• http://www.december.com/html/spec/colorcodes.html• This page shows a variety of notations used to represent color
including ways you can define colors in HTML or style sheets.
HTML
• With HTML (Hypertext Markup Language), colors are sometime described using their RGB color specification in hexadecimal.
HTML
• For example, the RGB code for Carrot Orange is #FF8E2A
• Or in decimal (255, 142, 42)
• How is FF8E2A the same as 255, 142, 42 ?
Why Hexadecimal?
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111
-----------------------------------------------------
• We said the hexadecimal RGB code for Carrot Orange is #FF8E2A or in decimal (255, 142, 42)
• Remember that this is using 24 bits for color or 3 bytes.
• Carrot Orange is
• In binary: 1111 1111 , 1000 1110 , 0010 1010
• In hexadecimal: F F , 8 E , 2 A
• In decimal: 255 , 142 , 42
Color Codes
Dec. Hex. Binary Dec. Hex. Binary
0 0 0000 8 8 1000
1 1 0001 9 9 1001
2 2 0010 10 A 1010
3 3 0011 11 B 1011
4 4 0100 12 C 1100
5 5 0101 13 D 1101
6 6 0110 14 E 1110
7 7 0111 15 F 1111