binary binary binary number system binary number system binary to decimal binary to decimal ...

16
Binary system…

Upload: shonda-burns

Post on 23-Dec-2015

246 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Binary system…

Page 2: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Binary Binary Number System Binary to Decimal Decimal to Binary Octal and Hexadecimal Binary to Hexadecimal Hexadecimal to Binary Hexadecimal to Decimal Any Number Base to Decimal Decimal to Any Number Base Binary Coded Decimal (BCD)

Topic to be discuss

Page 3: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

A computer is a “bistable” device A bistable device:

◦Easy to design and build◦Has 2 states: 0 and 1

One Binary digit (bit) represents 2 possible states (0, 1)

Binary

Page 4: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

With 2 bits, 4 states are possible (22 = 4)

• With n bits, 2n states are possible• With 3 bits, 8 states are possible (23 = 8)

Bit1 Bit0 State

0 0 1

0 1 2

1 0 3

1 1 4

Bit2 Bit1 Bit0 State

0 0 01

0 0 12

0 1 03

0 1 14

1 0 05

1 0 16

1 1 07

1 1 18

Go back

Page 5: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

From left to right, the position of the digit indicates its magnitude (in decreasing order)◦ E.g. in decimal, 123 is less than 321◦ In binary, 011 is less than 100

A subscript indicates the number’s base◦ E.g. is 100 decimal or binary? We don’t know!◦ But 1410 = 11102 is clear

Binary Number System

Go back

Page 6: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Binary is base 2 Example: convert 10110 (binary) to decimal

101102 = 1x24 + 0x23 + 1x22 + 1x21 + 0x20

= 1x16 + 0x8 + 1x4 + 1x2 + 0x1

= 16 + 0 + 4 + 2 + 0

= 22 So 101102 = 2210

Binary to Decimal

Go back

Page 7: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Binary is base 2 Example: convert 35 (decimal) to binary

Quotient Remainder

35 / 2 = 17 117 / 2 = 8 18 / 2 = 4 04 / 2 = 2 02 / 2 = 1 01 / 2 = 0 1

So 3510 = 1000112

Decimal to Binary

Go back

Page 8: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

It is difficult for a human to work with long strings of 0’s and 1’s

Octal and Hexadecimal are ways to group bits together

Octal: base 8 Hexadecimal: base 16

Octal and Hexadecimal

Page 9: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

With 4 bits, there are 16 possibilities

Use 0, 1, 2, 3, …9 for the first 10 symbols

Use a, b, c, d, e, and f for the last 6

HexadecimalBit3 Bit2 Bit1 Bit0 Symbol0 0 0 0 00 0 0 1 10 0 1 0 20 0 1 1 30 1 0 0 40 1 0 1 50 1 1 0 60 1 1 1 71 0 0 0 81 0 0 1 91 0 1 0 a1 0 1 1 b1 1 0 0 c1 1 0 1 d1 1 1 0 e1 1 1 1 fGo back

Page 10: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

01010110101100112 = ? in hex Group into 4 bits, from the right: 0101, 0110, 1011, 00112 Now translate each (see previous table):

01012 => 5, 01102 => 6, 10112 => b, 00112 => 3So this is 56b316

What if there are not enough bits? ◦ Pad with 0’s on the left

Binary to Hexadecimal

Go back

Page 11: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Hexadecimal to Binary• f0e516 = ? in binary

• Translate each into a group of 4 bits:

f16 => 11112, 016 => 00002, e16 => 11102, 516 => 01012

So this is 11110000111001012

Go back

Page 12: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Hexadecimal is base 16 Example: convert 16 (hex) to decimal

1616 = 1x161 + 6x160

= 1x16 + 6x1= 16 + 6= 22

So 1616 = 2210

Not surprising, since 1616 = 0001, 01102◦ If one of the hex digits had been > 9, say c, then we

would have used 12 in its place.

Hexadecimal to Decimal

Go back

Page 13: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

From right to left, multiply the digit of the number-to-convert by its baseposition

Sum all results

Any Number Base to Decimal

Go back

Page 14: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Take the decimal number, and divide by the new number base

Keep track of the quotient and remainder Repeat until quotient = 0 Read number from the bottom to the top

Decimal to Any Number Base

Go back

Page 15: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Why not use 4 bits to represent decimal? Let 0000 represent 0 Let 0001 represent 1 Let 0010 represent 2 Let 0011 represent 3, etc.

◦ This is called BCD◦ Only uses 10 of the 16 possibilities

Binary Coded Decimal (BCD)

Go back

Page 16: Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal

Thanks…..

Go back