3.3 Fundamentals Of Data Representation Flashcards
What is a bit (b)?
A single binary digit (1/0) in a binary code
What is a byte (B)?
A group of 8 bits
- big enough to store 1 character
Order of byte sizes ( /1000 each time)
Byte (B) Kilobyte (kB) (files) Megabyte (MB) Gigabyte (GB) (videos, storage) Terabyte (TB)
What are the different number bases?
- decimal (base 10)
(Standard number system, base-10 = 10 different digits (0-9)) - binary (base 2)
(Used by computers to represent data/instructions, base-2 = 2 different digits (0/1) - hexadecimal (base 16)
(Used regularly in programming, base-16 = uses combination of digits & letters to represent a number (0-9 & A-F)
Why must all data be converted into binary to be processed by a computer?
As computers only understand 1s and 0s
A bit pattern could represent different types of data (text, image, sound, integer)
Why do programmers often use hexadecimal when coding?
- simpler to remember large numbers (shorter than binary numbers)
- therefore less chance of input errors
- easier to convert between binary & hex, then binary & decimal
Draw an 8 bit table:
128 64 32 16 8 4 2 1
How do we convert from binary to decimal? Or read binary?
- place values from right to left increase by powers of 2 eg:
128 64 32 16 8 4 2 1
0 0 1 1 0 1 0 1 = 53
How do we convert from hexadecimal to decimal?
- place values increase from right to left by powers of 16
16 1
8 D = (8x16=128) + (13x1=13) = 141
What do hexadecimal digits represent?
0-9 = 0-9 A-F = 10-15
How do we convert from decimal to binary?
- draw table of binary place values then subtract from largest to smallest
How do we convert from decimal to hexadecimal?
Draw table, and then divide with remainders from left to right Eg.
Decimal number = 106 / 16 = 6 r 10, 10 / 1 = 10 = A so
16 1
6 A
So 106 = 6A
How do we convert from binary to hexadecimal?
- Split binary numbers into nibbles (4 bits)
- Draw table with columns 1, 2, 4, 8 from right to left then repeat for amount of nibbles
- For each nibble, add up numbers with binary value 1 and convert value to hex
- Put hex values together
Eg.
8 4 2 1 8 4 2 1
1 0 1 1 1 0 0 1
8+2+1=11, 8+1=9
11 = B, 9 = 9
So 10111001 = B9
How do we convert from hexadecimal to binary?
- Find decimal value for each hexadecimal character
- Find binary value of each decimal number in nibbles
- Put nibbles together
Eg.
8C 8 = 8, C = 12
8 4 2 1 8 4 2 1
1 0 0 0 1 1 0 0
So 8C = 10001100
How do we add together binary numbers?
1. Use column addition 0+0=0, 0+1=1, 1+1=1 0 (write 0 then carry 1 into next column), 1+1+1=1 1 (write 1 then carry 1 into next column) Eg. 0 1 0 0 1 0 1 1 \+ 1 0 0 0 1 0 0 1 \+ 0 0 1 0 0 1 0 1 = 1 1 1 1 1 0 0 1 1 1 1 1 Add 0 INFRONT of binary numbers if they have different number of bits
What are binary shifts used for?
For simple: - multiplications (left shift) - divisions (right shift) By powers of 2: ‘a’ place left/right shift = multiply/divide by 2ª
Binary shit can cause 1s to ‘drop off’ the end
What is the effect of losing 1s in a left shift?
What is the effect of losing 1s in a right shift?
Left shift = very different answer (check using decimal)
Right shift = inaccurate answer (rounded to nearest whole number, remainders and decimals not considered)
What is a character set?
Collection of characters a computer recognises from their binary representation
Including:
- alphanumeric characters (uppercase/lowercase letters, digits 0-9, symbols
- special characters (commands eg. delete)