02 Section 7 - Binary and Hexadecimal Flashcards
What base is denary/decimal in?
base-10
What base is binary in?
base-2
What are the units for 8 bits?
128 64 32 16 8 4 2 1
each column is just a power of 2
How do you convert from binary to decimal and back again?
Always lay out columns with the amount which can be in them, and work logically to work it out both ways
How do you add binary numbers?
By using column addition
- work from right to left
- 0+0 = 0, 0+1 = 1, 1+1 = 10
What is an overflow errors?
Overflow errors occur when a number has too many bits
- an overflow error from the computer getting extra bits, instead the computer will see the extra digit as an overflow error
- overflow flags are used to show that an overflow error has occurred
What are the problems with a computer and overflow errors?
An overflow error can lead to a loss of data and a loss of accuracy in the answer.
It could also cause software to crash if the program doesn’t have a way of dealing with the extra bit
What is Binary Shift/Logical Shift?
Binary shift is when you move every bit in a binary number left or right a certain number of places
- left shifts times the number by powers of 2
- right shifts divide the numbers by powers of 2
What problems can left and right shifts cause?
Left shifts can cause overflows
Right shifts can ‘drop off’
-these can both cause a loss of accuracy/data
What base are hexadecimal numbers in?
base-16
What does a single hex character represent in denary numbers or binary numbers?
One hex digit can represent
- decimal- 0-15
- binary- 4 bits (a nibble)
Why do programmers prefer hex when coding?
- it is simpler to remember large numbers in hex
- due to hex numbers being shorter, there is less chance of input errors
- easier to convert between binary and hex than binary and denary
How do base-16 represent all the characters?
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
What are the units in hex?
4096 256 16 1
How do you convert from Binary to Hex?
Convert Binary to Hex by splitting it into nibbles
- draw a table and convert each nibble into hex
- then put the hex digits together