A Level Computer Science Paper 1: 1.4.1 - Data Types - Using binary
This flashcard set introduces primitive data types provided by programming languages (such as integers and booleans), explains the denary (decimal) number system, and describes how subscripts indicate the base of numeric values (e.g., base 2, 10, or 16).
Primitive data types
One provided by a programming language
Integer, float, char, string, Boolean
Key Terms
Primitive data types
One provided by a programming language
Integer, float, char, string, Boolean
Denary
Base 10/decimal
Our number system
How to know what data type a value is in
It will have 2/10/16 written in subscript
Binary
Uses 1/0 multiplied by the base, starting from the right
The bases are all powers of 2<...
Converting from denary to binary
Put a 1 in the column that is closest to the denary value, subtract and repeat
Hexadecimal
Uses base 16
Letters A-F represent values 10-15
Related Flashcard Decks
Study Tips
- Press F to enter focus mode for distraction-free studying
- Review cards regularly to improve retention
- Try to recall the answer before flipping the card
- Share this deck with friends to study together
| Term | Definition |
|---|---|
Primitive data types | One provided by a programming language Integer, float, char, string, Boolean |
Denary | Base 10/decimal Our number system |
How to know what data type a value is in | It will have 2/10/16 written in subscript |
Binary | Uses 1/0 multiplied by the base, starting from the right The bases are all powers of 2 |
Converting from denary to binary | Put a 1 in the column that is closest to the denary value, subtract and repeat |
Hexadecimal | Uses base 16 Letters A-F represent values 10-15 |
Hexadecimal advantages | Quicker |
Converting hex to denary | Show workings Convert letters to digits, multiply by base and sum |
Converting denary to hex | Divide by 16, add the hex symbol of the remainder assuming 2 bit value |
Hex and binary conversions | Each hex value is 4 bits of binary |
Binary addition | Works similar to denary, carry over a 1 if you have to go back to 0 |
What happens if adding 2 8-bit numbers gives a 9-bit answer? | There is an overflow error and the computer just cuts off the last bit from its output |
| 0 -> (2^n) -1 where n is the number of bits |
Binary Subtraction | You make the second number into its negative value using Two’s Complement and then add them |
Sign and Magnitude | The first bit represents +/- and then the rest are the same The first bit being a 1 means the number is negative. |
Two’s Complement Grid | The leftmost column has the negative value of itself |
Sign and Magnitude Range | -(2^(n-1) + 1 -> (2^)n-1)) -1 |
Two’s Complement Process |
|
Two’s complement range |
|
What happens if there is overflow in binary subtraction? | You can ignore those bits |
What are the lsb and msb | lsb - least significant bit - the rightmost bit msb - most significant bit - the leftmost bit |
Logical shift left | Pushes every value 1 space to the left, the msb goes into the carry bit, 0 comes into the lsb |
Logical shift right | Pushes every value 1 space to the right, the lsb goes into the carry bit, 0 comes into the msb |
Logical shift sums | x2 for left, /2 for right as long as it isn’t two’s complement or sign and magnitude |
Arithmetic shift left | Pushes every value 1 space to the left but the msb doesn't move so the second bit from the left goes into the carry bit, 0 comes in as lsb |
Arithmetic shift right | Pushes every value 1 space to the right and the value that comes into the msb is whatever was there before |
Arithmetic shift sums | x2 for left, /2 for right, for all numbers |
Circular shift left | Pushes every value 1 space to the left, the msb into the carry bit and the carry bit into the lsb |
Circular shift right | Pushes every value 1 space to the right, the lsb into the carry bit and the carry bit into the msb |
Bitwise Masks | Apply another binary value with an AND, OR or XOR | Use boolean algebra on binary values by using each pair of corresponding values |
OR masking | 0: The output is the same as the input |
AND masking | 0: The output is 0 (clear the bit) |
XOR masking | 0: The output is the same as the input |
Fixed point binary | At a fixed point is a metaphorical decimal point, after that comes negative values of 2 |
First 5 coefficients after the fixed point | 0.5, 0.25, 0.125, 0.0625, 0.03125 |
How does moving the decimal point affect it? | Having more bits before the decimal point increases the range but decreases the accuracy |
What is a floating point binary number made up of | A mantissa and an exponent | mantissa x 2^exponent |
Where is the decimal point at the start in floating point binary? | Between the first 2 bits |
Positive floating point -> decimal |
|
Negative floating point -> decimal |
|
How to know if a mantissa/exponent is negative | It will have a 1 as the msb (in two's complement) |
Negative Exponents decimal conversions |
|
Doing two's complement on a binary number with a point | Add the 1 to the lsb |
Normalised positive number | Has a sign bit 0 and a 1 for the next bit |
Normalising a positive number |
|
Normalised negative number | Has a sign bit 1 and a 0 for the next bit. Leading 1s don't change the value. |
Normalising a negative number |
|
Positive denary -> floating point binary |
|
Negative denary-> floating point binary |
|
Floating point addition |
|
Floating point subtraction |
|