OCR A-Level Computer Science H446
Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation
Software Development
Types of Programming Language
Exchanging Data
Networks
Web Technologies
Data Types and Number Representation
Data Structures
Boolean Algebra
Legal, Moral, Cultural and Ethical Issues
Elements of Computational Thinking
Problem Solving and Programming
Algorithms
Data Types and Number Representation
- 9 subtopics
- 23 things to know
- Component 01
What Data Types and Number Representation covers
Data Types and Number Representation is examined on component 01 of OCR Computer Science, Computer systems. 152 recall questions across 9 subtopics.
Where it is assessed
Component 01
Computer systems, the whole of the first paper.
Check the OCR specification ↗The 9 subtopics
Each one has its own page.
- Primitive data typesRecall questions on integer, real, Boolean, character and string types, why 0.1 cannot be stored exactly, testing reals for equality, storing prices, concatenation versus addition, integer division and modulus, casting and overflow.Open →
- Binary, hexadecimal and denary conversionRecall questions on why computers use binary, place values and the number of values in n bits, converting between binary, denary and hexadecimal, the nibble shortcut, hexadecimal colour codes, and why programmers use hexadecimal.Open →
- Negative numbers: sign and magnitude and two's complementRecall questions on sign and magnitude and its two zeros, two's complement and the flip-and-add-one method, converting negative numbers both ways, ranges of each, subtracting with an adder, and sign extension.Open →
- Binary addition, subtraction and overflowRecall questions on binary addition and carries, binary subtraction with borrows and by adding a two's complement, overflow and how to detect it for unsigned and two's complement numbers, and guarding against overflow.Open →
- Floating point representation and normalisationRecall questions on the mantissa and exponent, reading positive and negative mantissas, representing values in floating point, the normalisation rules and how to normalise, largest and smallest storable values, underflow, and range versus precision.Open →
- Floating point addition and subtraction, and fixed point comparedRecall questions on aligning exponents and adding or subtracting floating point numbers, arithmetic shifts of the mantissa, normalising results, rounding and associativity, fixed point numbers and their range, and choosing between fixed and floating point.Open →
- Bitwise shiftsRecall questions on logical left and right shifts and their effect on value, bits lost off the end, arithmetic right shifts on two's complement numbers, rounding, compilers replacing multiplication with shifts, and extracting packed values.Open →
- Masks with AND, OR and XORRecall questions on bit masks, using AND to clear, isolate and test bits, OR to set bits, XOR to toggle bits and in simple encryption, testing for even numbers, packed settings, and converting letter case with a mask.Open →
- Character sets: ASCII and UnicodeRecall questions on character sets, standard and extended ASCII, control codes, working out codes and sorting by code, character digits versus numbers, why Unicode was needed, UTF-8, storage costs, and garbled text between machines.Open →
What you need to know
Answer each one before you reveal it.
What does a variable's data type actually tell the computer?
A shop program stores prices. Would you use a real to hold 19.99, and why?
In a language where + works on both, what is the difference between 5 + 3 and "5" + "3"?
Convert the denary number 156 to eight-bit binary using the place value method.
Why does hexadecimal need the letters A to F?
Convert the hexadecimal number 7A3 to binary.
What is the range of an eight-bit sign and magnitude number?
Give three reasons why two's complement is preferred to sign and magnitude.
What are the four rules for adding two binary digits in one column?
Add 11010110 and 01101001 in eight bits and say what happens at the left-hand end.
Add the eight-bit two's complement numbers 01000001 and 00011110 and decide whether overflow has occurred.
Using an eight-bit two's complement mantissa and a four-bit two's complement exponent, represent 5.75.
Now represent minus 5.75 in the same eight-bit mantissa, four-bit exponent format.
How do you read the value of a negative mantissa such as 10100100?
What is the first thing you must do before adding two floating point numbers, and why?
An eight-bit fixed point number has four bits before the point and four after. What is the value of 01101010?
Give two practical advantages of fixed point over floating point.
Shift 00010110 two places left. What is the result in binary and in denary?
Shift 01001100 two places right logically and check the result.
What is an arithmetic right shift, and how does it differ from a logical one?
What is the effect of XOR with 11111111, and of XOR with 00000000?
The plaintext byte 01101000 is XORed with the key 00110011. Show the ciphertext, and show that XORing again with the key recovers the original.
Take Data Types and Number Representation further
The same content, four other ways.
Commonly confused
Pairs that lose marks when they are blurred together.
Sign and magnitude vs Two's complement
Sign and magnitude: a representation reserving the leftmost bit to record the sign, the rest holding the size. Two's complement: a representation in which the leftmost bit carries a negative place value.
A fixed point binary number vs A floating point binary number
A fixed point binary number: a representation with the binary point at an agreed, unchanging position. A floating point binary number: a representation storing a mantissa and an exponent, so the point can move.
ASCII vs Unicode
ASCII: a character set of 128 codes in seven bits, extended to 256 in a full byte. Unicode: a character set assigning a code point to characters of every writing system.
Questions from this topic
Each one with the model answer underneath.
- 1
What does a variable's data type actually tell the computer?
Model answer
Two things. First, how much memory to set aside for the variable. Second, how to interpret the bit pattern stored there, and therefore which operations are legal on it and what those operations mean. The same eight bits could be a small integer, part of a real number, or a character code; only the type decides which.
- 2
Name the five primitive data types and state, in one line each, what they store.
Model answer
Integer: a whole number, positive or negative, with no fractional part. Real (also called floating point): a number that may have a fractional part. Character: a single symbol, stored as its code number from a character set. String: a sequence of characters of any length, including zero. Boolean: one of exactly two values, TRUE or FALSE.
- 3
Why is 'primitive' the right word for these types?
Model answer
They are the built-in types the language provides directly, rather than types the programmer composes out of other types. Arrays, records and objects are built from primitives; primitives are not built from anything smaller within the language.
- 4
An integer and a real number are both numbers. Why bother having two types?
Model answer
They are stored completely differently and behave differently. An integer is a plain binary place-value pattern, is exact, and arithmetic on it is fast. A real is stored as a mantissa and an exponent, is only an approximation for most values, and arithmetic on it is slower because the exponents have to be handled as well as the digits. Storing a whole number as a real would waste the range and introduce rounding error for no gain.
- 5
Explain why 0.1 cannot be stored exactly in a real (floating point) variable.
Model answer
Binary fractions can only represent sums of halves, quarters, eighths and so on. Converting 0.1 by repeated multiplication by 2 gives 0.0001100110011... recurring forever, so it never terminates. The computer has a fixed number of mantissa bits, so it stores a truncated version, which is very slightly wrong. The same is true of any denary fraction whose denominator is not a power of two.
- 6
Why is it dangerous to test two real numbers for exact equality?
Model answer
Because rounding errors mean two calculations that should give the same value may differ in the last bits. A total built by adding 0.1 ten times may not equal 1.0 exactly. The safe test is whether the difference between the two values is smaller than a small tolerance, rather than whether they are identical.
What is inside Levo
Six ways to work the same material.
Data Types and Number Representation revision questions
- What does Data Types and Number Representation cover in OCR A-Level Computer Science?
- 9 subtopics: primitive data types, binary, hexadecimal and denary conversion, negative numbers: sign and magnitude and two's complement, binary addition, subtraction and overflow, floating point representation and normalisation, floating point addition and subtraction, and fixed point compared, bitwise shifts, masks with and, or and xor and character sets: ascii and unicode. Each one has its own page with questions and model answers.
- How is Data Types and Number Representation organised?
- By the OCR H446 specification, subtopic by subtopic, so it matches the order you are taught it in.
Every question in Data Types and Number Representation, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.