NUMBER SYSTEMS
The Decimal (base-10) Number
System
Powers of 10
10-5 = 1/100,000 = .00001
10-4 = 1/10,000 = .0001
10-3 = 1/1,000 = .001
10-2 = 1/100 = .01
10-1 = 1/10 = .1
100 = 1
101 = 10
102 = 100
103 = 1,000
104 = 10,000
105 = 100,000
Evaluating a number in base-10
Example: 1,492.76
1,492.76 = (1x1,000) + (4x100) + (9x10) + (2x1) + (7x1/10)
+ (6x1/100)
1,492.76 = (1x103) + (4x102) + (9x101) + (2x100)
+ (7x10-1) + (6x10-2)
From this example, we see that the value of a number is the sum of the products of each digit multiplied by its positional value. That is, the 4 has a positional value of 100 (or 102), so its value is 400; 9 has a positional value of 10 (or 101), so its value is 90, and so. After we get the value of each digit, we add the values: 1,000 + 400 + 90 +2 + .7 + .06 = 1,492.76.
The Binary (base-2) Number System
Powers of 2
2-5 =1/32 = .03125
2-4 =1/16 = .0625
2-3 =1/8 = .125
2-2 =1/4 = .25
2-1 =1/2 = .5
20 = 1
21 = 2
22 = 4
23 = 8
24 = 16
25= 32
Evaluating a number in base-2
Example: 1010.11
1010.11 = (1x8) + (0x4) + (1x2) + (0x1) + (1x1/2) + (1x1/4)
1010.11 = (1x23) + (0x22) +(1x21) + (0x20)
+ (1x2-1) + (1x2-2)
In other words, evaluating a number is the same as in base-10, except that it
is easier. Since one times any number is that number,
and zero times any number is zero, we can rewrite our formula as: 1010.11 =
8+2+1/2+1/4, which equals 10.75 in
base-10.
Decimal to binary conversion
One method of conversion is to use the powers of two, as in the above example. Another method is repeated division (also known as the quotient-and-remainder method). You divide repeatedly by 2, and each time the remainder becomes a digit in the binary number.
Example: 29 in base-10 is equivalent to 11101 in base-2.
Method:
29/2 = 14 with a remainder of 1
14/2 = 7 with a remainder of 0
7/2 = 3 with a remainder of 1
3/2 = 1 with a remainder of 1
1/2 = 0 with a remainder of 1
So, using the remainders in reverse order, the number is 11101.
For a fractional number, the method of conversion is repeated multiplication
(also known as the product-and-carry method).
Example: .625 = .101
Method:
.625x2 = .250 with a carry of 1
.250x2 = .500 with a carry of 0
.500x2 = .000 with a carry of 1
So, using the carries, the number is .101.
Applying these methods to a number with both an integer and fractional
component:
10.75 = 1010.11 as follows:
10/2 = 5 with a remainder of 0
5/2 = 2 with a remainder of 1
2/2 = 1 with a remainder of 0
1/2 = 0 with a remainder of 1
So, using the remainders in reverse order, the number is 1010
Now for the fractional component:
.75x2 = .50 with a carry of 1
.50x2 = .00 with a carry of 1
So, using the carries, the number is .11.
Putting the two parts together, we get 1010.11
The Hexadecimal (base-16) Number
System
Powers of 16
16-4 = 1/65,536 = .000015258789
16-3 = 1/4,096 = .000244140625
16-2 = 1/256 = .00390625
16-1 = 1/16 = .0625
160 = 1
161 = 16
162 = 256
163 = 4,096
164 = 65,536
Evaluating a number in base-16
Example: 3AF.2
3AF.2 = (3x256) + (10x16) + (15x1) + (2x1/16) = 768 + 160
+ 15 + .125 = 943.125
Or we can write the formula as powers of the base:
3AF.2 = (3x162) + (10x161) + (15x160) + (2x16-1)
Conversions between base-2 and base-16
Even though it is cumbersome to convert to and from base-10, it is easy to go from hex to binary or vice versa.
8-4 = 1/4,096 = .000244140625
8-3 = 1/512 = .001953125
8-2 = 1/64 = .015625
8-1 = 1/8 = .125
80 = 1
81 = 8
82 = 64
83 = 512
84 = 4,096
Example: 347.2
347.2 = (3x64) + (4x8) + (7x1) + (2x1/8) = 192 + 32 + 7 + .25 = 231.25
Or we can write the formula as powers of the base:
347.2 = (3x82) + (4x81) + (7x80) + (2x8-1)
Binary Arithmetic
Addition
The basic rules are:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 with a carry of 1
Subtraction
Most computer systems perform subtraction by a method known as twos-complement addition. It works like this:
Example: 101 – 11 = 10 (in decimal, 5 – 3 = 2).
Method:
This may seem like a needlessly involved process, but the reason for it is that the only numeric operation a computer can actually do is addition, so other numeric operations must somehow be reduced to addition.
Multiplication and Division
Multiplication is just repeated addition: "2x3 = ?" is like asking "What do you get when you add three twos?"
Division is just repeated subtraction: "10/3 = ?" is like asking "How many times can you subtract 3 from 10 and what will be left over?"