1.4.1 Data Types Flashcards
What is a character set?
- A defined list of characters recognised by the computer hardware and software, with each character being represented by a single number
- Character sets are agreed standards for referring to all characters a computer uses
- Includes upper/lower case symbols and punctuation
How many unique binary numbers does 7 bits give?
128
What is ASCII?
- American Standard Code Information Interchange became the accepted standard.
- It was then extended from 7 bit to 8 bit - Extended ASCII
How many unique binary numbers with 8 bits?
256
An international, multilingual language character set needs to include:
- Characters from every written language
- Historical scripts
- Emojis
What is UNICODE?
- Was originally 16 bit but is now 24 bit character set providing over 16 million characters
- Writing 24 bits is slow, so hexadecimal is used instead
Why don’t we use UNICODE all the time?
- The ASCII Character set is an 8 bit character set, meaning each unique character in a file is represented by 8 1s or 0s
- The Unicode Character set is 8, 16 or 32 bit character set depending on version, therefore each character is either 8, 16 or 32 1s or 0s
- Text file stored using UNICODE can take up more space than ASCII
Exam Question: What is meant by the character set of a computer?
- Normally equates to the symbols on a keyboard/ digits/ letters
- That can be represented/ interpreted/ understood by a computer
- May include control characters
Exam Question: Explain how codes are used to represent a character set?
- Each symbol has a (binary) code / number
- Which is unique
- Number of bits used for 1 character = 1 byte
- Example code: ASCII / UNICODE
- Uses 8 bits/ 16 bits per character
- Use of more bits for extended character set
Exam Question: The character A in the ASCII character set is represented by the denary value 65. Write the binary representation for the ASCII character “H”. Show your working. (2)
- If A is 65, H is 72
- 72 in binary is 01001000
Describe what is meant by the term ASCII ?(2)
- American Standard Code for Information Interchange
- A character set
- Maps values to characters
- Uses 7 bits/8bits per character
Exam Question: Explain what is meant by the term UNICODE? (3)
- Unicode is a character set
- Mapping different binary values to characters
- Each character is represented by 1-4 bytes
- It supports a very large number of characters
- It is backward compatible with ASCII
What are the 5 primitive data types?
- Integer
- Real/floating point
- Character
- String
- Boolean
What is an integer and give an example?
- A whole number
- 23
What is a real/floating point and give an example?
- A number with an integer and a fractional part
- 12.65
What is a character and give an example?
- A single alpha-numeric character
- D
What is a string and give an example?
- A sequence of alpha numeric characters
- Hello
What is Boolean and give an example?
- Either TRUE or FALSE
- FALSE
How do you represent positive 11 in a 4 bit binary system?
- 1011
How do you represent 121 into binary?
- 01111001
What are the 2 ways to represent negative numbers in binary
- Sign and Magnitude
- Two’s complement
How do you use sign and magnitude to represent a negative number in binary?
- The most sig fig is used to represent the sign
- 1 means the number is negative and 0 means the number is positive
How would you convert -4 into binary using sign and magnitude?
- Write out positive 4 in binary
- Then change the MSB to 1
- 10000010
Why is Sign and magnitude not used often?
- Largest number that can be represented using 8 bits is 127 due to using MSB as a sign bit much less than 255
- Also harder to do calculations as some bits mean different things; some numbers and some signs
How do you represent a negative number using Two’s complement?
- To write it out as a positive number
- Then starting from the right hand side, flip each bit and then add 1
Convert -86 into binary using Two’s complement
- Work out + 86: 01010110
- Then flip: 10101001
- And add 1: 10101010
What is
- 0+0
- 0+1
- 1+1
- 1+1+1 ?
- 0
- 1
- 10
- 11
How do you do Binary Addition?
- Arrange them above each other
- Start at Least Significant Bit and add the 1s and 0s
How do you do Binary subtraction?
- Same as binary addition but convert the number to be subtracted into a negative number using 2s complement
Binary addition: What is 42+18
00111100
Binary subtraction: What is 68 - 33
- 00100011
What are the different symbols used in hexadecimal and what do they mean?
- 0 - 9 = 0 - 9
- A=10, B = 11, C=12, D=13, E = 14, F = 15
How do you convert the denary number 31 into hexadecimal?
- 1F
What are the steps of writing a number into floating point notation?
- Convert the exponent into denary.
- If the exponent is positive, move the decimal point to the right, if negative move decimal point to the left
- Put column headings under and add the value
How do you normalise a number - if positive?
- Convert exponent to denary
- Move decimal point so it is before the first 1
- Subtract the number of moves from the exponent
How do you add floating point numbers?
- The exponents of the 2 numbers must be the same
- Change the exponent of the 2nd number to the first exponent and adjust mantissa
- Add mantissas using usual method
Add Mantissa: 01110, Exponent 010 and Mantissa 01000, Exponent 001 together?
- 10010 010
How do you subtract floating numbers?
- Just like addition, exponents must be the same and adjust mantissa
- Now convert the mantissa of the second number to a negative one using 2s complement
- Add the mantissas
Subtract
Mantissa: 01110, Exponent: 010
from
Mantissa: 01000, Exponent 001
- 01010 010
What is Bitwise Manipulation and masks?
- Bitwise Manipulation means applying logical operators (AND, OR, NOT, XOR) to binary
- Mask is simply data being used in the operation
How do you carry out Bitwise Manipulation?
- Apply operations to corresponding bits
- A = 10111001
- B = 00111010
- AND = 00111000