Download Number Systems

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

History of logarithms wikipedia, lookup

Elementary arithmetic wikipedia, lookup

Elementary mathematics wikipedia, lookup

Addition wikipedia, lookup

Arithmetic wikipedia, lookup

Location arithmetic wikipedia, lookup

Approximations of π wikipedia, lookup

Positional notation wikipedia, lookup

Transcript
The Wonders of Conversion
 A number system is a system in which a number is
represented. There are potential infinite number
systems that can exist (there are infinite numbers,
after all), but you are only responsible for a very small
subset.
 For the AP Exam, you will need to know binary (base2), octal (base-8), decimal (base-10) and hexadecimal
(base-16).
 Notice that all of those bases are powers of 2!
 The binary number system is the one your computer
explicitly understands.
 All numbers are represented by bits, which is either a 0
or a 1.
 A byte is a collection of 8 bits, and can represent
numbers from -256 to 255. (The max value of a
collection of bits is always 2^numbits -1  28-1 = 255)
 For example, 10110110 is 182 in decimal.
 Octal is base-8. Only digits 0-7 are used.
 Using 182 again, it is 266 in octal.
 (That is not a typo – the number appears to be bigger!)
 Decimal is good old base-10. You’ve been using this all
of your lives!
 182 is 182 in decimal!
 Hexadecimal is base-16. It uses the digits 0-9 and the
letters A-F to represent 10-15, respectfully.
 For example, 15 base 10 is F in hexadecimal.
 16 is 10.
 890 is 37A.
 The following is called the expansion method and only
works on converting a number TO BASE-10!!!
 You need to understand how these numbers are
written. You have to analyze the number starting on
the right. This number represents the base number
raised to the 0th power.
 The second number from the right represents the base
number raised to the first power.
 …and so on
 Consider the following binary number:




01110011
What is this number in decimal format?
Start looking at the rightmost digit. This represents the
base number raised to the 0th power. Multiply this number
by the digit present (which is a 1). Save this number.
Look at the second rightmost digit. This represents the
base number raised to the first power. Multiply this
number by the digit present (which is a 1). Save this
number.
…do this for all numbers present and add all of products
together to get your base-10 number.
 01110011 to decimal
 20 * 1 = 1
 21 * 1 = 2
 22 * 0 = 0
 23 * 0 = 0
 24 * 1 = 16
 25 * 1 = 32
 26 * 1 = 64
 27 * 0 = 0
 The sum is 115.
 Convert 10101010 to decimal.
 Convert 00011111 to decimal.
 Convert 11110110 to decimal.
 Convert 234 base-8 to decimal.
 80 * 4 = 4
 81 * 3 = 24
 82 * 2 = 128
 The sum is 156.
 Convert 716 base-8 to decimal.
 Convert 45 base-8 to decimal.
 Convert 10 base-8 to decimal.
 REMEMBER:
 A = 10
 B = 11
 C = 12
 D = 13
 E = 14
 F = 15
 Convert F16 to decimal.
 Work:
 160 * 6 = 6
 161 * 1 = 16
 162 * 15 = 3840
 The sum is 3862.
 Convert C10 to decimal.
 Convert FF to decimal.
 Convert 16 to decimal.
 One method of converting any base number to base-10
is by continuously dividing the original decimal
number by the desired base until you get a quotient of
0, and then read the remainders backwards. Note: if
you are converting to hexadecimal, remember that
10..15 are represented by A..F respectively!)
 Convert 201 to binary.
 Work:








201 / 2 = 100 remainder 1
100 / 2 = 50 remainder 0
50 / 2 = 25 remainder 0
25 / 2 = 12 remainder 1
12 / 2 = 6 remainder 0
6 / 2 = 3 remainder 0
3 / 2 = 1 remainder 1
1 / 2 = 0 remainder 1.
 201 in binary is 11001001.
 Convert 1076 to binary.
 Convert 200 to binary.
 Convert 450 to binary.
 Convert 173 to octal.
 Work:
 173 / 8 = 21 remainder 5
 21 / 8 = 2 remainder 5
 2 / 8 = 0 remainder 2
 173 base-10 is 255 base-8.
 Convert 1076 to octal.
 Convert 200 to octal.
 Convert 450 to octal.
 Convert 506 to hexadecimal.
 Work:
 506 / 16 = 31 remainder 10
 31 / 16 = 1 remainder 15
 1 / 16 = 0 remainder 1
 BUT 10 is A and 15 is F so…
 506 base-10 is 1FA base-16.
 Convert 1076 to hexadecimal.
 Convert 200 to hexadecimal.
 Convert 450 to hexadecimal.
 There is a neat trick that allows one to convert from
binary to hexadecimal, without converting the binary
to base-10 first.
 Every base-16 digit (including letters) can be
represented by four bits:
Base -2
0000
0001
0010
0011
0100
0101
0110
0111
Base-16
0
1
2
3
4
5
6
7
Base-2
1000
1001
1010
1011
1100
1101
1110
1111
Base-16
8
9
A
B
C
D
E
F
 Convert 1001001010111 base-2 to base-16.
 Starting from the right, break up the binary number
into groups of 4 bits. If the last group doesn’t have
four bytes, pad it on the left with zeros.
 Base-2 groups: 0001 0010 0101 0111
 Base-16:
1
2
5
7
 Answer = 1257
 1111111110010001101 to base-16
 Groups:
 Base-2: 0111 1111 1100 1000 1101
 Base-16:
7
F
 Answer = 7FC8D
C
8
D
 Convert 73254 base-16 to base-2
 Groups:
 Base-16: 7
 Base-2: 0111
3
0011
2
0010
 Answer: 01110011001001010100
5
0101
4
0100
 Convert 1a2b3c to base-2
 Groups:
 Base-16: 1
a
 Base-2: 0001 1010
2
0010
b
1011
 Answer: 000110100010101100111100
3
0011
c
1100
 Convert 101101011010101101 to hexadecimal.
 Convert 111111111111111111101010 to hexadecimal.
 Convert 3f5a86 to binary.
 Convert aa4fc to binary.