1 1 7-Dec-15 Binary Converting to and from decimal.
-
Upload
paula-pierce -
Category
Documents
-
view
227 -
download
0
Transcript of 1 1 7-Dec-15 Binary Converting to and from decimal.
21 Apr 2023 11
Binary
Converting to and from decimal
21 Apr 2023 22
Decimal
We normally use the decimal (denary) system, also called base 10
There are 10 different symbols (digits) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 To count higher than nine we re-use the
symbols by putting them in columns The value of a symbol depends on its
position
21 Apr 2023 33
Decimal positions
1000 100 10 1
Thousands Hundreds Tens Units
8 2 5 3
Eight thousand two hundred and fifty three
21 Apr 2023 44
Binary
Computers use the binary system, also called base 2
There are two different symbols (digits) 0, 1 To count higher than one we re-use the
symbols by putting them in columns The value of a symbol depends on its
position
21 Apr 2023 55
Binary positions
8 4 2 1
Eights Fours Twos Units
1 1 0 1
One eight, one four, no twos and one unitThat makes thirteen
21 Apr 2023 66
Counting in binary and decimal
0 0 1000 8
1 1 1001 9
10 2 1010 10
11 3 1011 11
100 4 1100 12
101 5 1101 13
110 6 1110 14
111 7 1111 15
21 Apr 2023 77
Why do computers use binary?
Computer components that store or handle data are often two-state devices
This is like a switch that can be on or off A memory unit could exist in two voltage
states, high or low A voltage on a cable could be high or low A light could be on or off Two states can be coded by binary 0 and 1
21 Apr 2023 88
Why am I learning about binary?
In your Cisco course, you will learn about IP addresses and how to split up a network into subnets
You need to work out subnet addresses and workstation addresses
For this you need to use binary
21 Apr 2023 99
Bytes or octets
We often handle binary digits (bits) in groups of eight
Sometimes these groups are called bytes Sometimes they are called octets We shall often be calling them octets Examples of octets:
00101101
10110010
21 Apr 2023 1010
Convert binary to decimal
Value 128 64 32 16 8 4 2 1
Binary
Convert 11001010 binary to decimalWrite in the binary digits under their values
21 Apr 2023 1111
Convert binary to decimal
Value 128 64 32 16 8 4 2 1
Binary 1 1 0 0 1 0 1 0
Convert 11001010 binary to decimalWrite in the binary digits under their valuesNext write in the value for each binary 1 digit
21 Apr 2023 1212
Convert binary to decimal
Value 128 64 32 16 8 4 2 1
Binary 1 1 0 0 1 0 1 0
128 64 8 2
Convert 11001010 binary to decimalWrite in the binary digits under their valuesNext write in the value for each binary 1 digitAdd up the values 128 + 64 + 8 + 2 = 202
21 Apr 2023 1313
One for you to try
Convert 10010101 from binary (base 2) to decimal (base 10)
Value 128 64 32 16 8 4 2 1
Binary
21 Apr 2023 1414
Answer
Convert 10010101 from binary (base 2) to decimal (base 10)
Value 128 64 32 16 8 4 2 1
Binary 1 0 0 1 0 1 0 1
128 16 4 1
128 + 16 + 4 + 1 = 149
21 Apr 2023 1515
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary
Check
Convert 185 decimal to binaryCan you take 128 from 185? Yes.Put 1 under 128What is left? 185-128 = 57
21 Apr 2023 1616
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1
Check
We have 57 leftCan you take 64 from 57? No.Put 0 under 64What is left? Still 57
21 Apr 2023 1717
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0
Check
We have 57 leftCan you take 32 from 57? Yes.Put 1 under 32What is left? 57 – 32 = 25
21 Apr 2023 1818
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1
Check
We have 25 leftCan you take 16 from 25? Yes.Put 1 under 16What is left? 25 – 16 = 9
21 Apr 2023 1919
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1
Check
We have 9 leftCan you take 8 from 9? Yes.Put 1 under 8What is left? 9 – 8 = 1
21 Apr 2023 2020
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1 1
Check
Wwe have 1 leftCan you take 4 from 1? No.Put 0 under 4What is left? Still 1
21 Apr 2023 2121
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1 1 0
Check
We have 1 leftCan you take 2 from 1? No.Put 0 under 2What is left? Still 1
21 Apr 2023 2222
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1 1 0 0
Check
We have 1 leftCan you take 1 from 1? Yes.Put 1 under 1What is left? Nothing. Finished.
21 Apr 2023 2323
Convert 185 decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1 1 0 0 1
Check
185 decimal is 10111001 binary
21 Apr 2023 2424
Convert decimal to binary
Value 128 64 32 16 8 4 2 1
Binary 1 0 1 1 1 0 0 1
Check 128 32 16 8 1
Check: write in the values of the 1 digits and add them up128 + 32 + 16 + 8 + 1 = 185That’s the number we started with. It’s correct.
21 Apr 2023 2525
One for you to try
Convert 248 from decimal to binary Check your answer
Value 128 64 32 16 8 4 2 1
Binary
Check
21 Apr 2023 2626
Answer
Convert 248 from decimal to binary Check your answer
Value 128 64 32 16 8 4 2 1
Binary 1 1 1 1 1 0 0 0
Check 126 64 32 16 8
128 + 64 + 32 + 16 + 8 = 248
So 11111000 is correct.
21 Apr 2023 2727
End