How would a computer distinguish between signed and unsigned binary?
It cannot, the computer must be told.
Compare the set of number represented by signed and unsigned binary.
- Unsigned binary can only represent positive whole numbers.
- Signed binary can only represent both positive and negative whole numbers.
State an expression which describes the range of numbers which n-bit unsigned binary can represent.
0 to (2^n-1)
Boolean Addition Rules
0 1 0 carry 1 1 carry 10 + 0 + 0 = ?
0 + 0 + 1 = ?
0 + 1 + 1 = ?
1 + 1 + 1 = ?
Multiplication of two unsigned binary numbers.
https://www.youtube.com/watch?v=mAxUtloyk_IState an expression which describes the range of numbers which b-bit signed binary with twos complement can represent.
Write decimal -5 in signed with twos complement 4-bit binary.
The (leftmost) significant bit is a negative number in the legend.
- (-)8 4 2 1
- ---1 0 1 1
(-)8 + 2 + 1 = -5 decimal
State the steps needed to convert an unsigned to two's complement (positive to negative).
Invert every bit, then add 1.
State the steps needed to convert a negative two's complement to (negative to positive)
Subtract 1, then invert bits.
Subtract 12 from 8 in binary.
- Convert larger number to negative.
- Convert both numbers to binary.
- -16 8 4 2 1
- __1 0 1 0 0
- -16 8 4 2 1
- __0 1 0 0 0
- Perform binary addition.
- 1 0 1 0 0
- 0 1 0 0 0
- 1 1 1 0 0
12 -> -12
-12 in signed two's complement binary is...
8 in signed twos complement binary is...
Adding -12 binary to 8 binary.
11100 signed two's complement binary in decimal is...
- -16 8 4 2 1
- __1 1 1 0 0
12 - 8 = -4 decimal as well!
Convert 11.75 to fixed point unsigned binary.
- 16 8 4 2 1 . 0.5 0.25
- _0 1 1 0 1 . __1 ___1
Convert 01101 . 011 floating point two's complement signed binary to decimal.
- Calculate the decimal value of the exponent.
- Place a binary point between the first and second digits of the mantissa.
- Move the binary point specified by the decimal exponent.
0 1 1 = 3 decimal
0 1 1 0 1 → 0 . 1 1 0 1
Three places to the right.
0 . 1 1 0 1 → 0 1 1 0 . 1
- -8 4 2 1 . 0.5
- _0 1 1 0 . __1
Convert decimal 14.625 to floating point signed binary.
- Convert to fixed point signed binary.
- -16 8 4 2 1 . 0.5 0.25 0.125
- __0 1 1 1 0 . __1 ___0 ____1
- Normalise.
- Decide how far to move point using these two rules.
- Positive number so mantissa starts with 01.
- If we jad a negative number, mantissa starts with 10.
- Determine exponent using these two rules.
- Since we've shifted left 3, exponent is +3.
- If we've shifted right 3 exponent is -3.
- Convert exponent (-3) to two's complement signed binary.
- -4 2 1
- _0 1 1
- Concatenate mantissa and exponent like this.
01.110101 + 011 -> 01110101.011
The number 14.6 is represented in fixed point binary as 1110.1. Calculate the absolute error.
- Convert binary to decimal.
- 8 4 2 1 . 0.5
- 1 1 1 0 . __1
- Absolute error = actual value - given value.
14.6 - 14.5 = 0.1
The number 12.4 is represented in fixed point binary as 1100.011. Calculate the relative error as a percentage 4 s.f.
- Convert binary to decimal.
- 8 4 2 1 . 0.5 0.25 0.125
- 1 1 0 0 . __0 ___1 ____1
- Absolute error = actual value - given value.
- Relative error = absolute error / actual value
8 + 4 + 0.25 + 0.125 = 12.375 decimal
12.4 - 12.375 = 0.025 decimal
0.025 / 12.4 * 100 = 20.16%
Compare qualitatively and explain the ranges of fixed point binary and floating point binary
Range of floating point binary > range of fixed point binary, because exponent of floating point binary can be both positive and negative.
Compare qualitatively and explain the ranges of a floating point binary number with (large mantissa and small exponent) and a (small mantissa and a large exponent).
- (large mantissa and small exponent) = large range + little precision
- (small mantissa and a large exponent) = small range + large precision
While mantissa size directly proportional to precision.
State when an underflow error might occur.
Not enough bits to represent very small number.
State when an overflow error might occur.
Not enough bits to represent a large number.