This preview shows pages 1–2. Sign up to view the full content.
Math Section
Range = Base ^ N
i.e. 16 bits (bits are base 2) has range of 2^16 = 64K 2^32 4G (billion)
Binary Multiplication is shifting
110101
×
1001
110101
+110101000
Converting
from Base
to Decimal
13754
base8 to Decimal
8
4
× 1 +
8
3
× 3 +
8
2
× 7 +
8
1
× 5 +
8
0
(1) × 4 = 6124
Other Method Multiplying
1 ×8 = 8 + 3 = 11
11 ×8 = 88 + 7 = 95
95 × 8 = 760 + 5 = 765
765 × 8 = 6120 + 4 = 6124
Converting
from Decimal to Base
6124 to Base5
Algorithmic Division
6124 / 5 = 1224 r
4
1224 / 5 = 244 r
4
244 / 5 = 48 r
4
48 / 5 = 9 r
3
9 / 5 = 1 r
4
1 / 5 = 0 r
1
=143444
Brute Force
– divide by largest 5^n
6124 / 3125(or 5^5)=
1
2999 / 625(or 5^4) =
4
499 / 625(or 5^3) =
3
124 / 25(or 5^2) =
4
24 / 5( or 5^1) =
4
4 / 5^0 =
4
143444 base5
Related Bases
Bases 2, 4, 8, 16… are related
0011 010 1 1101 1000 = 35D8 Hex, 32730 Octal, 113120 base4
Multiplication and Adding Hex (other bases’ principle is the same)
F +F = 1E (15 + 15 = 30 – 16 (Next Place) = 14 (1E, 1(16) + 14))
F × F = E1 (15 × 15 =225 / 16 = 14 r1 remainder becomes 1s place, so E 1)
Representing Numerical Data
Binary Coded Decimal  BCD:
represents each digit with 4 bits. i.e. 8 bit storage
range would be 0 – 99, 99 =1001 1001, 50 =0101 0000, 8=0000 1000
Drawbacks are:
 BCD has a range that is less than conventional binary representation
Calculations in BCD are more difficult for the computer thus slower
Signed Integer Representation
Changing the leftmost digit in Binary to a 0(+) or 1(). This divides the bit range in
half effectively, and creates the double zero problem. In addition, if the signs don’t
agree, the result will be incorrect.
i.e. 0…0100(4) + 1…0010(2) = 1…0110 (6)
Overflow – when the result does not fit into the fixed # of bits for a result. If both
inputs to an addition have the same sign and the output sign is different overflow
has occurred.
One’s Complement:
Add two #s
01101010 = 106
+11111101 = 2 (+2 is 00000010, change 0’s to 1’s)
101100111 (carry over take the leftmost 1 and add it back)
+1
01101000 = 104
Two’s Complement
Positive # in One’s and Two’s complement are equal
Negative # in two’s complement is found by writing the # in binary, inverting the
digits and adding 1
i.e. Find 28 in Two’s
0001 1100 28 Binary
+1 add 1
1110 0100 = 28 in Two’s
Other complements – take each digit and subtract it from the # complement, i.e. 16s
complement of 4C4D = F2 FC F4 FD or D3B2
Little Man Computer
Take input
IN
901
Print Output
OU
T
902
Store num to Address
ST
O
3xx
Load num from Address
LD
A
5xx
Add num in Address to accum
AD
D
1xx
Sub num in Address from accum
SU
B
2xx
Branch to address unconditionally
BR
6xx
Branch to address
if accum value is 0
BR
Z
7xx
Branch if accum value is positive (0 is
positive)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 11/06/2011 for the course CS 240 taught by Professor Wong during the Fall '10 term at Bentley.
 Fall '10
 wong

Click to edit the document details