Week 2 - Binary codes Flashcards
How do we represent unsigned numbers in binary code?
Unsigned binary codes are positional like the decimal system used in ordinary arithmetic.
Each digit carries a weight depending on its position in the code word.
In decimal allowed digits are 0,1,2,…,9; in binary only 1s and 0s are allowed
What is the base number of a positional code?
The position of a digit is weighted using powers of the base.
The lowest weighted digit is the least significant and the highest is the most significant.
How would you break down the decimal positional code 2053 with base 10?
2053 with base 10 = 2x10^3 + 0x10^2 + 5 x 10^1 + 3 x 10^0
= 2000+0+50+3
How would you break down the binary positional code 1001 with base 2?
1001 with base 2 = 1x2^3 + 0x2^1 + 1x2^0
= 8+0+0+1 = 9
How do you do decimal to binary conversion?
If we’re trying to convert the whole number x into binary, we need at least k bits, where k is the smallest power of 2 bigger than x.
Think: How many bits is it? Write the powers for the number of bits Work out what can be summed to = the decmial number & put a 1 under these numbers Then the rest should have 0s
Convert 203 base 10 to 8-bit binary.
First note the largest power of 2 in 8-bit positional number is 128.
x = 203; Is x > 128 ? If yes, write 1 and (203-128 = 75) x = 75; Is x>64? If yes, write 1 and (75-64 = 11) x=11; Is x>32? No, write 0 Is x>16? No, write 0 Is x>8? Yes, write 1 and x=11-8=3 x=3; ... ... ... ...
Add the two 4-bit numbers (unsigned binary addition)?
x=1010 and y=1111
11001
look at week 2, lecture slide 7 for full solution if stuck
What is 11001 base 2 in base 10?
25
What is unsigned overflow?
If we add two n-bit unsigned numbers, and the sum is too big to be an n-bit number, the sum cannot be represented in the n-bit code.
What is the necessary and sufficient condition for unsigned overflow?
The carry from the most significant bit (MSB) position is 1.
What is an n-bit unsigned adder?
An n-bit unsigned adder is a device which takes in two n-bit unsigned binary code words and outputs an n-bit number representing the sum.
What is a practical adder?
It’s an extra wire that signals whether we have a carry out and if there’s been an overflow. A practical adder should signal when there is an overflow. This can be done using the carry from the most significant bit (MSB) position. This is often referred to as the adder’s carry out (C).
What is hexadecimal and why do we convert binary code words into them?
Binary codewords can be very long and difficult for humans to work with. We can shorten binary strings to base 16 number representation (called hexadecimal). Needs digits 0 up to 15. We use 0,1,2,3,4…,9,a,b,c,d,e,f
How do you turn the hex digits to 4-bit binary?
3 a 6 e
0011 1010 0110 1110
See week 2, video 4, 5min for more details.
What is the maximum number of a 16-bit unsigned code?
65,535