number systems binary and hexadecimal. base 2 a.k.a. binary binary works off of base of 2 instead...

24
Number Systems Binary and Hexadecimal

Upload: marilyn-tate

Post on 26-Dec-2015

227 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Number SystemsBinary and Hexadecimal

Page 2: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Explaining Binary

Page 3: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Base 2 a.k.a. Binary

Binary works off of base of 2 instead of a base 10 like what we are taught in school

The only numbers that are able to be represented are 1 and 0

Binary numbers are read right to left (inverse way of reading, normal way of reading numbers)

Page 4: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

How to read binary numbers Since binary is base 2, every bit that

follows the first number in the sequence represents the previous number raised to the power of 2

So 100011101 = 256+0+0+0+16+8+4+0+1 = 285

Page 5: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Another way

Repeat Division Basically divide by 2 a lot If the quotient has a remainder of 1,

write down 1, if not write down 0 Keep dividing until you reach zero Keep in mind, do not automatically put

the remainders in fraction form

Page 6: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Example of Repeat Division

117 ÷2 58 remainder 1 ÷2 29 remainder 0 ÷2 14 remainder 1 ÷2 7 remainder 0 ÷2 3 remainder 1 ÷2 1 remainder 1 ÷2 0 remainder 1

Page 7: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Two’s complement On the IB exam they will probably ask you

to write a number using two’s complement Two’s complement is a way to write

negative numbers in binary Basically you take the last number in the

sequence (the largest number), and make it negative

You can then create any negative number less than the absolute value of the largest number

Page 8: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Example of two’s complement

Page 9: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

How to write decimal points in binary (Floating Point)

Simply add the decimal, and after the decimal follow the same pattern as you would with numbers greater than 1

Instead of each bit after the decimal being 2n, it is 2-n.

Page 10: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Example

MSB LSB

==

Page 11: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Binary Math

Page 12: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Adding in Binary

Remember these:0 + 0 = 01 + 0 = 10 + 1 = 11 + 1 = 101 + 1 + 1 = 10 + 1 = 11

In the case of a 10 or 11, “carry the one” one digit to the left, just like in normal (base 10) addition.

Page 13: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Examples

1 11 1 11 101+ 1 +11 + 10=10 =110 =111 1 1 1001010 +1101101=10110111

Page 14: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Subtracting in Binary

Remember these:0 – 0 = 01 – 0 = 11 – 1 = 0

0 -1 is a special case. Essentially, it requires you to carry a 1 from the left, just like in normal subtraction.

Page 15: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Examples

2 02 002 02 100 1100101- 10 - 110010= 10 =0110011

Page 16: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Explaining Hexadecimal

Page 17: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Base 16 A.K.A. Hexadecimal Hexadecimal works off a

base of 16. It uses sixteen distinct

symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen.

In base 10 (normal) numbers, for example, 14 means (1*10) + 4. In Hexadecimal, 1D means (1*16) + D (which is 13), or 29.

0 = 0 1 = 1 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 8 9 = 9 A = 10 B = 11 C = 12 D = 13 E = 14 F = 15

Page 18: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Some Hexadecimal Examples F is 15 10 is (1*16) + 0, or 16. 1F is (1*16) + 15, or 31. FF is (15*16) + 15, or 255. 1FF is (1*162) + (15*16) + 15, or 511. etc.

Page 19: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Binary/Hexadecimal Conversion Examples

Binary Hex Binary Hex 0000 0 1000 8 0001 1 1001 9 0010 2 1010 A 0011 3 1011 B 0100 4 1100 C 0101 5 1101 D 0110 6 1110 E

111 7 1111 F

Page 20: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Hexadecimal Math

Page 21: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

How to add hexadecimal Remember to think in base 16 when doing

Hexadecimal Math. If the value is greater than or equal to 16 you

carry a 1 over to the next column, and write down the value you received from the addition minus 16

If the number that you receive from addition is greater than 32, then you subtract 32, write down the value, and carry a two over to the next column

Etc.

Page 22: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Examples

11 1 1 12 91A 2F A AF 1F2 +3A +B F+E37 69 16 +FA1943 1B8

Page 23: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Subtraction in Hexadecimal Subtraction works very similar to

subtraction with decimal values Just remember that if you borrow a 1

from a column to the left, the borrowed 1 is equal to 16 (not 10).

Page 24: Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school

Example subtraction

F F 18 5 10 10 12 7 12 E 8 11

6 0 0 2 B 8 2 F 9 1

- 3 4 7 A 8 -1 5 9 E B 2 B 8 8 3 6 D 5 A 6