Lecture 8 Sign/Magnitude Addition and Subtraction Flashcards

1
Q

What is sign extension?

A

Computers perform sign extension to ensure consistent bit lengths for arithmetic operations while preserving value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is sign extension done in sign/magnitude representation?

A

Pad the number with 0’s after the sign bit until the desired length is reached.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the algorithm for addition in sign/magnitude representation?

A
  1. Determine signs of operands.<br></br>2. If signs are the same, add magnitudes.<br></br>3. If signs differ, subtract smaller magnitude from larger and keep sign of larger.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is subtraction performed in sign/magnitude representation?

A

Flip the sign bit of the subtrahend and perform addition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an example of sign extension in sign/magnitude?

A

Extending 0b1011 (4 bits) to 10 bits:<br></br>Sign: 1, Magnitude: 011 → Extended: 0b1000000011.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What issue exists with sign/magnitude representation?

A

The existence of both +0 and -0 leads to inefficiencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is one’s complement representation?

A

A number format where the most significant bit is the sign bit, and negation is done by flipping all bits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you convert -16 to one’s complement (6-bit)?

A

Write +16 in binary: 0b010000, then flip all bits: 0b101111.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is two’s complement representation?

A

A format where negation is done by flipping bits and adding 1, removing the problem of ±0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you find the two’s complement of a number?

A

Negate all bits and add 1: \( \text{Two’s complement} = \text{One’s complement} + 1 \).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an example of two’s complement conversion?

A

Convert -16 to 5-bit two’s complement:<br></br>+16 = 0b10000, flip bits: 0b01111, add 1: 0b10000.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when adding in two’s complement?

A

Addition works naturally, but overflow can occur if the result is out of range.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you perform subtraction in two’s complement?

A

Convert subtraction into addition: \( C = A - B = A + (-B) \), then use normal binary addition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is sign extension in two’s complement?

A

Extend the sign bit (MSB) to match the required bit length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an example of sign extension in two’s complement?

A

Sign extend 0b1101 (4-bit) to 8-bit:<br></br>0b1101 → 0b11111101.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why is two’s complement preferred in hardware?

A

It simplifies arithmetic operations and eliminates the need for extra processing logic.