Number Systems
Computers only store 0s and 1s. This is how ordinary numbers turn into those, and back.
//Denary → binary: take what fits
Write the place values down first, then go left to right. At each one ask: does it fit in what is left? If yes write 1 and subtract it; if no write 0. Here is 200.
128 64 32 16 8 4 2 1
1 1 0 0 1 0 0 0
128 fits -> 200 - 128 = 72
64 fits -> 72 - 64 = 8
32 no, 16 no
8 fits -> 8 - 8 = 0
answer: 11001000//Binary → denary: add up the 1s
Write the place values above the digits and add the ones with a 1 underneath.
1 0 1 1 0 1
32 16 8 4 2 1
32 + 8 + 4 + 1 = 45//Hexadecimal is binary in groups of four
Split the binary into nibbles from the RIGHT, then convert each nibble on its own. This is the whole trick — you never need to divide by 16.
1100 1000
| |
C 8 -> C8
A=10 B=11 C=12 D=13 E=14 F=15//Binary addition, and spotting overflow
Add column by column, carrying just like denary. 1+1 = 10 (write 0, carry 1). If a carry falls off the left-hand end and you only have that many bits, that is overflow — the answer is wrong and you must say so.
1 0 1 1 (11)
+ 0 1 1 0 (6)
---------
1 0 0 0 1 (17)
In 4 bits only 0001 could be stored -> OVERFLOW//Logical shifts
Shifting left by 1 multiplies by 2; shifting right by 1 divides by 2 (whole number). Zeros come in at the empty end, and any bits pushed off the end are LOST — always mention the loss if the question asks about the effect.
0000 1010 = 10
shift LEFT 1
0001 0100 = 20
0000 1010 = 10
shift RIGHT 1
0000 0101 = 5KEY TERMS
CHECK YOURSELF
1.What is 1101 in binary as a denary number?
2.Why do people use hexadecimal rather than binary?
3.A number is shifted LEFT by 1 place. What happens to its value?
4.Adding two 8-bit numbers gives a 9-bit result. What is this called?