CSE 30 -- Lecture 2 -- Sep 29
Change of base
A number N is represented in base b as a sequence of
N = sumi=0k-1 di bi
where each of the di are allowed to take on values
between 0 and b-1 inclusive.
The addition, subtraction, multiplication, and division algorithms in
other bases are the obvious translations of the same algorithms that
we use for base 10. Integer multiplication and division by the base
corresponds to adding a trailing zero and deleting the trailing (least
significant) digit respectively. Testing for divisibility by
b-1 is done by testing the sum of all the digits in the base
b representation, just like testing for divisibility by 9 in
We went over how to convert a base 10 number to and from another base,
as well as a fast method for converting between bases 16 and 2.
Numbers in computers are represented as sequences of bits. With the
usual interpretation of a sequence of binary digits, we get
non-negative numbers. For example, if we had four bits, they would be
Interpreting bit strings as numbers
and we have hardware in the ALU that would add, subtract, multiply etc
bit representations interpreted as numbers in the above manner.
To get negative numbers, we interpret the bit patterns differently but
use the same addition and subtraction hardware. We ask which numbers
when added together will give a zero result, if we ignored overflows.
When we add 1111 to 0001, we get 0000 ignoring overflows, so 1111 is
the additive inverse of 0001. Since 0001 is 1, 1111 must be -1. This
gives the following:
Multiple interpretations of bit strings as numbers
Here, the most significant bit is interpreted as the sign bit.
One Instruction Computer
The computer has 64K words and each word contains 48 bits (expressed
as 12 hexadecimal digits). The single instruction is:
which is encoded in the 48 bit word as
The instruction loaded from mem[PC] is divided into 3 fields
to extract the a,b,c values (each a 16-bit number), and
performs the following:
mem[a] = mem[a] - mem[b];
if (mem[a] >= 0) PC = c;
else PC = PC + 1;
Read chapter 4.
Use the turnin program to turn in a file with answers to the
following problems. You must show your work.
where the letters A-F is used to represent 10-15 in base 16, and A-H
are used to represent 10-17 in base 18. Plain ASCII text will be
fine; you don't need to do fancy formatting. To show that a number is
written in a certain base, you can write the base in parenthesis after
the number, e.g., DEADBEEF(16). The base is expressed in base 10.
| CSE home
| bsy's home page
| webster i/f
email@example.com, last updated Mon Nov 30 21:53:21 PST 1998.email bsy & tutors