The binary number system Flashcards
What does two’s complement enable?
For signed integers to be represented in binary, not just unsigned
Explain the two’s complement method of representing binary numbers
In a string of n bits, the most significant bit represents -(2ⁿ⁻¹), instead of just 2ⁿ⁻¹
Given the representation of a number n in binary, how can the representation of -n be calculated in two’s complement?
If necessary, pad the number with a preceding 0. Then, find the least significant 1. Flip all bits that are more significant than this 1
Explain the fixed point method of representing binary numbers
A binary point is positioned somewhere in the number. The bits to the left of this work like regular binary, the values doubling as they get closer to the most significant bit. The bit to the right of the point represents a half, and the values half as they get closer to the least significant bit
Explain the floating point method of representing binary numbers
A string of bits consists of two parts, a mantissa and an exponent, with each allocated a certain number of bits. By default, the binary point is positioned after the most significant bit. The exponent gives how many places to the right the binary point should be moved. The mantissa should be in normalised form. If there are not enough bits to fully store the mantissa, the least significant bit(s) get removed until it fits
Give an advantage of floating point representation compared to fixed point
A much wider range of numbers can be produced with the same number of bits
Give two advantages of fixed point representation compared to floating point
- They are faster to process as there is no processing required to move the binary point
- The absolute error will always be the same
What is overflow?
When a number is too large to be represented with the number of bits allocated
What may happen during overflow in a two’s complement system?
Two positive numbers may add together to produce a negative, due to the most significant bit changing to a 1
What is underflow?
When a number is too small to be represented with the number of bits allocated
What is normalisation?
The notion that a floating point binary number should have a mantissa starting with either 0.1 for a positive number of 1.0 for a negative number
Give an advantage of normalisation
It provides maximum precision for a given number of bits
How can a floating point binary number be normalised?
By moving the binary point such that the mantissa starts with either 0.1 or 1.0, and then adjusting the exponent accordingly
What is the absolute error of a number that has been rounded?
The difference between the exact value and the approximation
What is the relative error of a number that has been rounded?
The absolute error divided by the exact value