# binary numbers ... binary notation → 11000000 . 10101000 . 10000011 . 01101001 to convert...

Post on 24-Apr-2020

3 views

Category:

## Documents

Embed Size (px)

TRANSCRIPT

• BINARY NUMBERS

Converting decimal numbers to binary numbers

What are binary

numbers and why do

we use them?

• Thousands Hundreds Tens ones

4 3 5 1

The number system we commonly use is decimal numbers, also known as

Base 10. Ones, tens, hundreds, and thousands.

For example, 4351 represents 4 thousands, 3 hundreds, 5 tens, and 1 ones.

• Thousands Hundreds Tens ones

4 3 5 1 However, a computer does

not understand decimal

numbers. It only understands

“on and off,” “yes and no.”

• Thousands Hundreds Tens ones

4 3 5 1

In order to convey “yes and

no” to a computer, we use the

numbers one (“yes” or “on”)

and zero (“no” or “off”).

• DECIMAL NUMBERS (BASE 10)

4351

4x1000 3x100 5x10 1x1

To break it down further, the

number 4351 represents

1 times 1, 5 times 10,

3 times 100, and 4 times 1000.

Each step to the left is another

multiplication of 10. This is why

it is called Base 10, or decimal

numbers. The prefix dec-

means ten.

• DECIMAL NUMBERS (BASE 10)

4351

4x1000 3x100 5x10 1x1

103=1000 102=100 101=10 100=1

One is 10 to the zero power.

Anything raised to the zero power

is one.

Ten is 10 to the first power (or 10).

One hundred is 10 to the second

power (or 10 times 10).

One thousand is 10 to the third

power (or 10 times 10 times 10).

• Base 10

103 102 101 100

1000 100 10 1

Base 2

23 22 21 20

8 4 2 1

Binary numbers, or Base 2,

of the number 10.

The prefix bi- means two.

• Base 10

103 102 101 100

1000 100 10 1

Base 2

23 22 21 20

8 4 2 1

Two raised to the zero

power is one.

Two raised to the first

power is two.

Two raised to the second

power is four (or 2 times 2).

Two raised to the third

power is eight

(or 2 times 2 times 2).

• Base 2

23 22 21 20

8 4 2 1

27 26 25 24

128 64 32 16

BINARY NUMBERS (BASE 2)

And so on…

Eight times two is

sixteen, or two to the

fourth power.

Sixteen times two is

thirty-two, or two to

the fifth power.

• Base 2

23 22 21 20

8 4 2 1

27 26 25 24

128 64 32 16

BINARY NUMBERS (BASE 2) Thirty-two times two

is sixty-four, or two to

the sixth power.

And sixty-four times

two is one hundred

twenty eight, or two

to the seventh power.

• DECIMAL

15

1

101=10

5

100=1

BINARY

15

1

23=8

1

22=4

1

21=2

1

20=1

15 1111

The number fifteen is written

in decimal as one ten and five

ones. In binary, the number fifteen

is written as one eight, one four,

one two, and one one.

These are called bits, and they are

either one (on) or zero (off).

• 8 BITS = 1 BYTE = 1 OCTET

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

Eight bits make a byte.

This is also known as an octet.

When you see an IP address, it is

made up of four octets (or 32 bits).

• 8 BITS = 1 BYTE = 1 OCTET

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

x x x x x x x x

0 0 0 0 0 0 0 0

= = = = = = = =

0 + 0 + 0 + 0 + 0 + 0 + 0 + 0

= 0

If every bit is a zero…that’s eight zeros…

and we multiply each power of two by zero,

the decimal equivalent of that octet is zero.

• 8 BITS = 1 BYTE = 1 OCTET

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

x x x x x x x x

0 0 0 0 0 0 0 0

= = = = = = = =

0 + 0 + 0 + 0 + 0 + 0 + 0 + 0

= 0

x x x x x x x x

1 1 1 1 1 1 1 1

= = = = = = = =

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1

= 255

If every bit is a one…that’s eight ones…

and we multiply each power of two by one,

the decimal equivalent is two hundred and

fifty-five.

Therefore, each octet can have a value

between 0 and 255.

• Decimal notation → 192 . 168 . 131 . 106

Binary notation → 11000000 . 10101000 . 10000011 . 01101001

Let’s look at an IP address.

It is easier for us to recognize decimal numbers, so

we write the IP address as 192.168.131.106.

However, a computer sees the IP address in binary

notation as four octets of ones and zeros.

• 27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 . 10000011 . 01101001

To convert binary numbers to decimal numbers, we use

the powers of two again.

Write the octet below…one in the 128 column, one in

the sixty-four column, and zeros for the rest.

1 1 0 0 0 0 0 0

• 128 64 32 16 8 4 2 1

1 1 0 0 0 0 0 0

128 + 64 + 0 + 0 + 0 + 0 + 0 + 0 =

Binary notation → 11000000 . 10101000 . 10000011 . 01101001

196

Then multiply each column

plus zero equals 196.

• 128 64 32 16 8 4 2 1

1 0 1 0 1 0 0 0

128 + 0 + 32 + 0 + 8 + 0 + 0 + 0 =

Binary notation → 11000000 . 10101000 . 10000011 . 01101001

Decimal notation → 196

168

Write the second octet, multiply down and add across.

128 plus 0 plus 32 plus 8 plus 0 equals 168.

• Decimal notation → 192 . 168 . 131

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 .

131

-128 31

Now we’ll convert the other way…from decimal to

binary…for the third and fourth octets.

To convert 131 to binary…we start from the left.

Can we subtract 128 from 131?

Yes. So we put a one in the 128 column, and we are

left with three.

• Decimal notation → 192 . 168 . 131

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 .

131

-128 31 0 0 0 0 0

Can we subtract 64 from 3? No. So we put a

zero in the 64 column.

Can we subtract 32 from 3? No. Another

zero for the 32 column.

Zero in the 16 column, the 8 column, and the

four column.

• Decimal notation → 192 . 168 . 131

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 .

131

-128 31 0 0 0 0 0 1 1 -2

1 -1

0

10000011 .

Can we subtract a 2 from 3? Yes, and

we put a one in the two column. We

are left with one in the one column.

So 131 in binary is 10000011.

• Decimal notation → 192 . 168 . 131 . 106

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 .

106

-64 420 1 1

-32

10

10000011 .

Now we’ll convert the fourth octets. Starting from the left.

Can we subtract 128 from 106? No.

Can we subtract 64 from 106? Yes, and we are left with 42.

Can we subtract 32 from 42? Yes, leaving 10.

• Decimal notation → 192 . 168 . 131 . 106

128 64 32 16 8 4 2 1

Binary notation → 11000000 . 10101000 .

106

-64 420 1 1 0 1 0 1 0

-32

10 -8

2

10000011 . 01101010

Can we subtract 16 from 10? No.

Can we subtract 8 from 10? Yes, leaving 2.

Can we subtract 4 from 2? No.

Can we subtract a 2 from 2? Yes, leaving 0.

So, 106 written in binary is 01101010.

• I hope this has helped you understand a little bit