Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal.

Similar presentations


Presentation on theme: " Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal."— Presentation transcript:

1

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

3  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)

4  With 2 bits, 4 states are possible (2 2 = 4) With n bits, 2 n states are possible With 3 bits, 8 states are possible (2 3 = 8) Bit 1 Bit 0 State 00 1 01 2 10 3 11 4 Bit 2 Bit 1 Bit 0 State 0001 0012 0103 0114 1005 1016 1107 1118 Go back

5  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 14 10 = 1110 2 is clear Go back

6  Binary is base 2  Example: convert 10110 (binary) to decimal 10110 2 = 1x2 4 + 0x2 3 + 1x2 2 + 1x2 1 + 0x2 0 = 1x16 + 0x8 + 1x4 + 1x2 + 0x1 = 16 + 0 + 4 + 2 + 0 =22  So 10110 2 = 22 10 Go back

7  Binary is base 2  Example: convert 35 (decimal) to binary QuotientRemainder 35 / 2 = 171 17 / 2 = 81 8 / 2 = 40 4 / 2 = 20 2 / 2 = 10 1 / 2 = 01  So 35 10 = 100011 2 Go back

8  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

9  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 Bit 3 Bit 2 Bit 1 Bit 0 Symbol 000 00 000 11 001 02 001 13 010 04 010 15 011 06 011 17 100 08 100 19 101 0a 101 1b 110 0c 110 1d 111 0e 111 1f Go back

10  0101011010110011 2 = ? in hex  Group into 4 bits, from the right:  0101, 0110, 1011, 0011 2  Now translate each (see previous table): 0101 2 => 5, 0110 2 => 6, 1011 2 => b, 0011 2 => 3 So this is 56b3 16  What if there are not enough bits? ◦ Pad with 0’s on the left Go back

11 f0e5 16 = ? in binary Translate each into a group of 4 bits: f 16 => 1111 2, 0 16 => 0000 2, e 16 => 1110 2, 5 16 => 0101 2 So this is 1111000011100101 2 Go back

12  Hexadecimal is base 16  Example: convert 16 (hex) to decimal 16 16 = 1x16 1 + 6x16 0 = 1x16 + 6x1 = 16 + 6 =22  So 16 16 = 22 10  Not surprising, since 16 16 = 0001, 0110 2 ◦ If one of the hex digits had been > 9, say c, then we would have used 12 in its place. Go back

13  From right to left, multiply the digit of the number-to-convert by its base position  Sum all results Go back

14  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 Go back

15  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 Go back

16


Download ppt " Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal."

Similar presentations


Ads by Google