Goals

To create a representation of integers which

1) Allows negative numbers to be represented.

2) Has only one representation of zero.

3) Allows numbers to be added as if they were unsigned binary numbers.


Signed Magnitude Representation

S Magnitude

Basic Idea

If S is 0 the number is positive.

If S is 1 the number is negative.

Problem 1: Two representations of zero.

Problem 2: Cannot add them as if they were unsigned and always get the right answer.


Ones Complement Representation

Basic Idea

Positives are just like signed magnitude.

Flip the Bits to get the negative.

The ones become zeroes and the zeroes become ones.

Problem 1: Two representations of zero.

Problem 2: You can add them as if they were unsigned, but you need to add back in the end carry. This wastes time.


Twos Complement

Basic Idea

Positives are just like signed magnitude.

Flip the bits and then add one to get the negative.

1 followed by all zeroes is the most negative integer.

Computers often use a twos complement representation for integers because:

1) We want to represent negative numbers too.

2) There is one representation of zero.

3) We can build cost effective and time efficient circuits to perform unsigned binary addition.

4) We can add two twos complement numbers as if they were unsigned, ignore the end carry, and it always produces the correct number. This is not true for either a signed magnitude representation or a ones complement representation.


IEEE 754 Single Precision Floating Point Format

You are given 32 bits.

The leftmost bit is the sign bit.

The next 8 bits represent the exponent.

The exponent uses an excess 127 notation.

The final 23 bits represent the mantissa.

There are normalized and denormalized numbers.

Normalized numbers use an implied one.

There are special cases.

What do you need to know how to do?

Take a decimal fraction and be able to convert it into its IEEE 754 equivalent.

Basic Idea

Step 1: Form the binary fraction equivalent.

Step 2: Move the binary point to the right of the leftmost one. Keep track of how many positions you moved it. Did you move it left or right?

Step 3. Adjust 127 by the number of positions you moved the binary point. Add if moved it left. Subtract if moved it right.

Step 4: Record the sign bit.

Step 5: Record the 8 exponent bits.

Step 6: Take all the bits to the right of the binary point and record them. The implied one is not recorded, but it is understood to be there.

Let’s do some on the board.

ASCII

What do you need to know?

1) What does ASCII stand for?

American Standard Code for Information Interchange

2) How to read an ASCII chart. Your text book has an its ASCII chart on page 725.

3) Four specifics pieces of information. They are:

a) That “all zeroes” is called the null byte.

b) That the space, also known as blank, is decimal 32.

c) That upper case letters and their lower case counterparts are off by 32.

d) That the character for number zero is decimal 48. From this you should be able to recall all the digits.

4) In C an ASCII character is represented as an unsigned integer using the decimal number that it has been assigned . For example, the letter ‘A’ is decimal 65. This is 00100001.

Write out the answer as a sequence of 0s and 1s.
The character 3 using the ASCII chart
The integer 3 using a 32 bit twos complement representation
The number 3.0 using an IEEE 754 representation.

Unit 2: Signed Magnitude Representation Study Guide 91.101 Computing I

You need to know …

U2-1) how to convert a decimal number into its n-bit signed magnitude equivalent.

U2-2) how to convert an n-bit signed magnitude number into its decimal equivalent.

U2-3) what is the largest and smallest n bit number that can be represented as a signed magnitude integer.

U2-4) that adding two signed magnitude numbers as if they were unsigned does not necessarily produce a correct answer.

U2-5) that a signed magnitude representation has two representations of zero.

Question 1: Fill in the table below.

Decimal Value / 2 Bit Signed Magnitude
+1
0
0
-1

Question 2: If you are given two bit positions what is the largest decimal number that could be represented using a signed magnitude representation?

Question 3: If you are given two bit positions what is the smallest decimal number that could be represented using a signed magnitude representation?


Question 4: Fill in the table below.

Decimal Value / 4 Bit Signed Magnitude
7
6
5
4
3
2
1
0
0
-1
-2
-3
-4
-5
-6
-7

Question 5: If you are given 4 bits, what is the largest decimal number that could be represented using a signed magnitude representation?

Question 6: If you are given 4 bits, what is the smallest decimal number that could be represented using a signed magnitude representation?

Question 7: Fill in the table below.

Number of Bits Given / Largest decimal number that could be represented in signed magnitude. / Smallest decimal number that could be represented in signed magnitude.
1
2
3
4
5
6
7
8
9
10
11
12

Question 8: If you were given n bit positions what is the range of decimal values that can be represented using a signed magnitude scheme? Your response should use n in an expression.

Question 9: Please represent the decimal number 5 as a four bit signed magnitude number.

Question 10: Please represent the decimal number -2 as a four bit signed magnitude number.

Question 11: Please add your answer to question 9 to your answer to question 10. Perform the addition as if you were adding two unsigned numbers.

Question 12: Look at the result you obtained in the previous problem. Interpret these bits as if they were a signed magnitude representation. What is the decimal equivalent of these bits if they are to be interpreted as a signed magnitude number? Notice that your answer is not 3.

Question 13: Please list two flaws with a signed magnitude representation.

Question 14: Suppose you have 12 bits to work with. Please represent the following decimal numbers using a signed magnitude representation.

Decimal Value / 12 Bit Signed Magnitude
500
-500
18
-18

Question 15: The following 16 bit pattern is a signed magnitude representation of some decimal number. What decimal number is being represented?

0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1


Question 16: Fill in the table below.

Here is the correct spelling of a word. / Please print the correct spelling of the work here.
receive
separate
programmer
integer
bookkeeper

Question 17: I have noticed that students often confuse the word then with the word than. Many times I see the word then being misused when a student is comparing two quantities. For example, there is a tendency to write something like -

“I would rather be at college feeling the freedom, joy, and power of learning then sitting on the couch.”

This is a classic misuse of the word then. The correct word is than.

Try not to do this.


Unit 3: Ones Complement Representation 91.101 Computing I

You need to know …

U3-1) how to convert a decimal number into its n-bit ones complement equivalent.

U3-2) how to convert an n-bit ones complement number into its decimal equivalent.

U3-3) what is the largest and smallest decimal number that can be represented as an n-bit ones complement number.

U3-4) that adding two ones complement numbers as if they were unsigned will always produced a correct result provided you add the leftmost carry-out back into the sum. This, of course, will cause a time delay.

U3-5) that the ones complement representation has two representations of zero.

Question 1: Fill in the table below.

Decimal Value / 2 Bit Ones Complement
+1
0
0
-1

Question 2: If you are given two bit positions what is the largest decimal number that could be represented using a ones complement representation?

Question 3: If you are given two bit positions what is the smallest decimal number that could be represented using a ones complement representation?


Question 4: Fill in the table below.

Decimal Value / 4 Bit Ones Complement
7
6
5
4
3
2
1
0
0
-1
-2
-3
-4
-5
-6
-7

Question 5: If you are given 4 bits, what is the largest decimal number that could be represented using a ones complement representation?

Question 6: If you are given 4 bits, what is the smallest decimal number that could be represented using a ones complement representation?


Question 7: Fill in the table below.

Number of Bits Given / Largest decimal number that could be represented in ones complement. / Smallest decimal number that could be represented in ones complement.
1
2
3
4
5
6
7
8
9
10
11
12

Question 8: If you were given n bit positions what is the range of decimal values that can be represented using a ones complement scheme? Your response should use n in an expression.

Question 9: Please represent the decimal number 5 as a four bit ones complement number.

Question 10: Please represent the decimal number -2 as a four bit ones complement number.

Question 11: Please add your answer to question 9 to your answer to question 10. Perform the addition as if you were adding two unsigned numbers. If there is a leftmost carry out, add this bit back into the sum.

Question 12: Look at the result you obtained in the previous problem. Interpret these bits as if they were a ones complement representation. What is the decimal equivalent of these bits if they are to be interpreted as a ones complement number? Notice that your answer is 3. If you did not get 3, then you need to redo the problem.

Question 13: Please list two flaws with a ones complement representation.

Question 14: Suppose you have 12 bits to work with. Please represent the following decimal numbers using a ones complement representation.

Decimal Value / 12 Bit Ones Complement Number
500
-500
18
-18

Question 15: The following 16 bit pattern is a ones complement representation of some decimal number. What decimal number is being represented?

0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1

Question 16: By now you should realize that the signed magnitude representation and the ones complement representation have identical bit patterns for positive numbers. To reinforce this, please fill in the table below.

Decimal Value / 5 bit signed magnitude representation / 5 bit ones complement representation
15
14
13
12
3

You are a full time student.

Your job is to become a scholar.

You are on the varsity team.

Show up for practice.

Now is your time to be a student. Be a student.


Unit 4: Twos Complement Representation 91.101 Computing I

You need to know …

U4-1) how to convert a decimal number into its n-bit twos complement equivalent.

U4-2) how to convert an n-bit twos complement number into its decimal equivalent.

U4-3) what is the largest and smallest decimal number that can be represented as an n bit twos complement number.

U4-4) that adding two twos complement numbers as if they were unsigned will always produced a correct result and you can ignore the leftmost carry out.

U4-5) that a twos complement representation has one representation of zero.

Question 1: Fill in the table below.

Decimal Value / 2 Bit Twos Complement
+1
0
-1
-2

Question 2: If you are given two bit positions what is the largest decimal number that could be represented using a twos complement representation?

Question 3: If you are given two bit positions what is the smallest decimal number that could be represented using a twos complement representation?


Question 4: Fill in the table below.

Decimal Value / 4 Bit twos Complement
7
6
5
4
3
2
1
0
-1
-2
-3
-4
-5
-6
-7
-8

Question 5: If you are given 4 bits, what is the largest decimal number that could be represented using a twos complement representation?

Question 6: If you are given 4 bits, what is the smallest decimal number that could be represented using a twos complement representation?

Question 7: Fill in the table below.

Number of Bits Given / Largest decimal number that could be represented in twos complement. / Smallest decimal number that could be represented in twos complement.
1
2
3
4
5
6
7
8
9
10
11
12

Question 8: If you were given n bit positions what is the range of decimal values that can be represented using a twos complement scheme? Your response should use n in an expression.

Question 9: Please represent the decimal number 5 as a four bit twos complement number.

Question 10: Please represent the decimal number -2 as a four bit twos complement number.

Question 11: Please add your answer to question 9 to your answer to question 10. Perform the addition as if you were adding two unsigned numbers. If there is a leftmost carry out ignore it.

Question 12: Look at the result you obtained in the previous problem. Interpret these bits as if they were a twos complement representation. What is the decimal equivalent of these bits if they are to be interpreted as a twos complement number? Notice that your answer is 3. If you did not get 3, then you need to redo the problem.

Question 13: Please explain why twos complement is the preferred representation for integer values. Give me two reasons (besides saving money).

Question 14: Suppose you have 12 bits to work with. Please represent the following decimal numbers using a twos complement representation.

Decimal Value / 12 Bit Twos Complement Number
500
-500
18
-18

Question 15: The following 16 bit pattern is a twos complement representation of some decimal number. What decimal number is being represented?