This content can't be printed from the browser. Use Export PDF with Pro for an offline copy.
IB Syllabus Requirements for Data representation and computer logic
A1.2.1
Representing integers and converting number bases
A1.2.2
Storing data using binary encoding
A1.2.3
Logic gates and Boolean operators
A1.2.4
Building truth tables and simplifying expressions
A1.2.1
REPRESENTING INTEGERS AND CONVERTING NUMBER BASES
Writing an integer in a different number base changes how it looks, but its value stays the same. You should be able to explain the place-value system and convert integers between binary, decimal and hexadecimal.
Binary uses base 2, so its only digits are 0 and 1. Each digit is a bit. Moving one position to the left doubles the place value.
In Decimal, also called denary, the base is 10 and the digits are 0–9. Each place value is a power of 10.
Hexadecimal uses base 16, with digits 0–9 and letters A–F. Those letters stand for decimal values 10–15.
| Hexadecimal digit | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Decimal value | 10 | 11 | 12 | 13 | 14 | 15 |
The examples here use non-negative integers. Leading zeros don't change the value: binary 00101101 and binary 101101 represent the same integer.
Start by writing the place value above each bit of binary 00101101. Multiply each bit by its place value, then add the results. The figure shows why this bit pattern represents decimal 45.
Binary place values and contributions for 00101101.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| Contribution | 0 | 0 | 32 | 0 | 8 | 4 | 0 | 1 |
| Total | ||||||||
| Decimal value |
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| Contribution | 0 | 0 | 32 | 0 | 8 | 4 | 0 | 1 |
Decimal value = 0 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 45.
Divide the decimal integer by 2 and record the remainder. Keep dividing each quotient by 2 until the quotient is 0.
| Division | Quotient | Remainder |
|---|---|---|
| 45 divided by 2 | 22 | 1 |
| 22 divided by 2 | 11 | 0 |
| 11 divided by 2 | 5 | 1 |
| 5 divided by 2 | 2 | 1 |
| 2 divided by 2 | 1 | 0 |
| 1 divided by 2 | 0 | 1 |
Read the remainders from bottom to top to get 101101. If you need an eight-bit representation, add leading zeros: 00101101.
From right to left, hexadecimal place values begin 1, 16 and 256. For hexadecimal 2D:
Divide repeatedly by 16, recording the remainder at each step.
| Division | Quotient | Remainder |
|---|---|---|
| 45 divided by 16 | 2 | 13, written D |
| 2 divided by 16 | 0 | 2 |
Reading the remainders from bottom to top gives 2D.
Four bits have 16 possible patterns, so one hexadecimal digit corresponds to exactly four bits. This makes hexadecimal a shorter, more readable way to write binary values.
To convert binary 00101101:
If the leftmost group has fewer than four bits, complete it with leading zeros.
Work on each hexadecimal digit separately. Convert it into four bits, then join the groups.
Terms to use: binary, hexadecimal, decimal, integer, bit.
A1.2.2
STORING DATA USING BINARY ENCODING
Binary storage assigns bit patterns to values. To explain how it works, start with the original data and its encoding. Show how that encoding becomes bits, then explain how the system interprets those bits when it retrieves them.
Binary encoding represents data as patterns of 0s and 1s. Computer hardware distinguishes between two physical states, such as two voltage ranges, and treats them as binary values.
A byte contains eight bits. Storage systems hold sequences of bits, but the encoding and format determine what those sequences mean.
Take the byte 01000001. It can represent the integer 65. Under a character encoding that assigns 65 to the character A, that same byte represents A instead. The bits alone don't tell the system which interpretation to use.
The encoding process figure follows original data → encoding → stored bits → decoding → retrieved data. To retrieve the data correctly, the system needs both the stored bits and the rules for decoding them.
An integer uses a binary bit pattern with positional values. For example, decimal 45 can be stored as 00101101 in an eight-bit field.
The number of bits allocated limits how many different values can be represented. Eight bits provide 256 patterns. If all of them represent non-negative integers, the range is 0–255. More bits allow a larger range, but each value then takes up more storage.
A character encoding assigns numeric codes to characters. These codes are then represented in binary.
ASCII and Unicode are examples of systems for representing characters. Unicode supports a much wider range of writing systems and symbols. An encoding such as UTF-8 determines how Unicode characters are stored as bytes.
A string is a sequence of characters, stored as their encoded representations in the same order. In a variable-length encoding, different characters can need different numbers of bytes. Character count alone therefore doesn't determine storage size.
A bitmap image stores a grid of pixels, each with a binary value describing its colour or brightness.
The image format must identify the image dimensions and specify how to interpret the pixel values. An RGB representation, for example, stores red, green and blue components for each pixel.
Two choices directly affect storage:
For an uncompressed image, storage for the pixel data is width × height × bits per pixel. Format information adds to this total.
Digital audio stores measurements of a sound signal taken at regular intervals. Each sample uses a binary value to approximate the signal's amplitude at that instant.
The sample rate is the number of samples taken per second. Bit depth is the number of bits used to represent each sample.
A higher sample rate records changes in the signal more frequently; a greater bit depth provides more possible amplitude values. Both increase the amount of uncompressed audio data. Duration and the number of audio channels also affect storage.
Digital video represents moving images through a sequence of frames. Each frame contains encoded image information, while timing information determines when it is displayed. Video may also include an audio stream that must stay synchronized with the frames.
Higher frame resolution and greater colour depth generally increase the amount of uncompressed video data, as do a higher frame rate and a longer duration. Compression can reduce the stored size by representing the content more efficiently.
The comparison figure links each data type to the information its bits represent.
How binary values are interpreted for common data types.
| Data type | What the binary data represents | Information needed for interpretation |
|---|---|---|
| Integer | A numeric value | Number representation and field width |
| Character | A character code | Character encoding |
| String | An ordered sequence of character codes | Character encoding and sequence boundaries |
| Image | Pixel colours or brightness values | Dimensions, colour depth and image format |
| Audio | A sequence of amplitude samples | Sample rate, bit depth and channels |
| Video | Frames, timing information and possibly audio | Frame dimensions, frame rate and video format |
| Data type | What the binary data represents | Information needed for interpretation |
|---|---|---|
| Integer | A numeric value | Number representation and field width |
| Character | A character code | Character encoding |
| String | An ordered sequence of character codes | Character encoding and sequence boundaries |
| Image | Pixel colours or brightness values | Dimensions, colour depth and image format |
| Audio | A sequence of amplitude samples | Sample rate, bit depth and channels |
| Video | Frames, timing information and possibly audio | Frame dimensions, frame rate and video format |
Storage requirements depend on how many values are represented and how many bits each value needs. More detail usually means more data to store and transfer.
To retrieve data, the system must locate it and decode it using the correct format. Some formats place values in fixed positions. Others require the system to interpret variable-length data or decompress it. Using an incorrect encoding can produce unreadable text or incorrectly interpreted media, even when the stored bits haven't changed.
Terms to use: binary encoding, data storage, retrieval, integers, strings, characters, images, audio, video.
A1.2.3
LOGIC GATES AND BOOLEAN OPERATORS
Logic gates take binary inputs, perform operations on them and produce binary outputs. You should be able to describe what each gate does and explain how gates support computation and control in a computer.
A logic gate is an electronic circuit that carries out a Boolean operation. Two logical states represent its inputs and output: 0 and 1, which can also be interpreted as false and true.
A Boolean operator gives the rule for combining or changing Boolean values. The gate carries out that rule in hardware, while the operator can also be used in a Boolean expression.
Most gates covered here take two inputs, A and B. NOT takes just one. When gates are connected, the output of one operation becomes the input of another. Simple operations can therefore build more complex circuits.
| Operator | Output rule | Output is 1 when… |
|---|---|---|
| AND | Both inputs must be 1 | A = 1 and B = 1 |
| OR | At least one input must be 1 | A = 1, B = 1, or both |
| NOT | Inverts its single input | Its input is 0 |
| NAND | The inverse of AND | The inputs are not both 1 |
| NOR | The inverse of OR | Both inputs are 0 |
| XOR | The inputs must differ | Exactly one input is 1 |
| XNOR | The inputs must match | Both are 0 or both are 1 |
OR is inclusive: when both inputs are 1, it still produces 1. XOR excludes that case. NAND, NOR and XNOR invert AND, OR and XOR respectively.
Compare how the two-input gates respond to the same inputs in the table below.
Truth-table comparison with each gate beside its inverted counterpart.
| A | B | AND | NAND | OR | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| A | B | A AND B | A OR B | A NAND B | A NOR B | A XOR B | A XNOR B |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
For NOT, there are only two possible input cases:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Gates turn binary representations into useful actions and results. For example:
These aren't the only possible uses. Networks of gates in a computer implement arithmetic, comparisons and decisions by applying the same Boolean rules repeatedly to binary signals.
Terms to use: logic gates, binary computing, Boolean operators, AND, OR, NOT, NAND, NOR, XOR, XNOR.
A1.2.4
BUILDING TRUTH TABLES AND SIMPLIFYING EXPRESSIONS
To construct a truth table, list every possible input combination, then work through the logic one operation at a time. To analyse it, find the rows where the output is 1. Check whether a simpler expression gives exactly the same outputs.
A room-access system releases a door only when a pass is valid and either the holder is a supervisor or restricted hours are not in effect.
First, define exactly what each input and the output represent:
This gives the Boolean expression Y = A AND (B OR NOT C). The brackets tell you to calculate the OR result before combining it with A.
With n independent binary inputs, there are 2 to the power n possible input combinations. For three inputs, you need eight rows.
List A, B and C in a systematic binary-counting order. Calculate NOT C first. Use that result to find B OR NOT C, then apply the final AND with A. The figure includes these intermediate columns alongside the output.
Worked truth table for the room-access expression.
| NOT | OR NOT | AND OR NOT | |||
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
| A | B | C | NOT C | B OR NOT C | Y = A AND (B OR NOT C) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
Take the row where A = 1, B = 0 and C = 1. NOT C is 0, which makes the OR result 0 too. The pass is valid, but the door remains locked.
Work through the diagram from its inputs towards its output. Name each intermediate gate output and give it a column in the table. Don't skip a gate just because the full expression looks familiar.
For the room-access circuit, work through the gates in this order:
N and T correspond to the NOT C and B OR NOT C columns in the table above. Working gate by gate predicts the circuit's output for every possible input.
You can also work backwards from a truth table to an expression. For each row where Y = 1, write an AND term that matches that exact input combination. Keep an input unchanged if its value is 1; negate it if its value is 0. Then join the terms with OR.
Here, the output is 1 for input combinations 100, 110 and 111. These give:
Y = (A AND NOT B AND NOT C) OR (A AND B AND NOT C) OR (A AND B AND C).
The expression is correct, but it can be shorter. Any simplified expression must preserve the output in every row—not just in selected cases.
A Karnaugh map arranges truth-table outputs so that neighbouring cells differ in only one input. Grouping adjacent 1s shows which inputs can be removed from terms.
For this three-input example, put A on the rows and BC on the columns. Use the column order 00, 01, 11, 10, rather than ordinary binary-counting order. The map wraps around, so the first and last columns are adjacent too.
Three-input Karnaugh map; overlap at and wrap-around pair –.
| / | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 |
| A / BC | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 |
Arrange adjacent 1s into rectangular groups containing a power-of-two number of cells, such as 1, 2, 4 or 8. Choose the largest valid groups. Every 1 must be covered, and no group may include a 0. Groups can overlap.
For this map:
Join the groups to get Y = (A AND NOT C) OR (A AND B). The cell at BC = 10 belongs to both groups; that overlap is allowed.
Boolean algebra offers another way to reach the same result. Start with the three output-1 terms:
Using the distributive rule, the Karnaugh-map result factors to the same expression. Equivalent expressions may look different on the page. Identical truth-table outputs establish that they implement the same logic.
Terms to use: truth table, inputs, outputs, Boolean expression, logic diagram, Karnaugh map, algebraic simplification.
A1.2.5
CONSTRUCTING AND SIMPLIFYING LOGIC DIAGRAMS
To construct a logic diagram, turn each Boolean operation into a gate, then connect the gates in the order the expression requires. Label the inputs and intermediate signals, along with the final output, so the flow of information is clear.
A logic diagram shows gates and the connections that carry signals between them. In the commonly used shaped-symbol notation, a small circle called an inversion bubble shows that a signal is inverted.
| Gate | Standard symbol features |
|---|---|
| AND | Flat input side and rounded output side, forming a D-like shape |
| OR | Curved input side and curved sides meeting at a pointed output |
| NOT | Triangle with an inversion bubble at its output |
| NAND | AND symbol with an inversion bubble at its output |
| NOR | OR symbol with an inversion bubble at its output |
| XOR | OR symbol with an additional curved line on the input side |
| XNOR | XOR symbol with an inversion bubble at its output |
NOT has one input; the other gates in these examples have two. Keep signal flow consistent, normally from left to right. Inputs enter the input side of each gate, and the output leaves the output side.
Mark connected wires with a junction dot. If wires cross without a junction dot, don't treat them as connected.
For Y = A AND (B OR NOT C), build the circuit from the innermost operation outwards:
The signal relationships are N = NOT C, T = B OR N and Y = A AND T. A goes directly to the final AND gate, not through the OR gate.
For A = 1, B = 0 and C = 0, the NOT gate produces N = 1. The OR gate then produces T = 1, and the AND gate produces Y = 1. Working through the connections this way follows the order in which the signal is processed.
The output of one gate can feed another, while a signal can branch to several gate inputs. The connections determine the expression. Correct gate types connected in the wrong order do not produce an equivalent circuit.
For example, implement Y = NOT ((A AND B) OR C) as follows:
You can replace the final OR and NOT with a single NOR gate receiving P and C. An AND followed by NOT can likewise be replaced by NAND; an XOR followed by NOT can be replaced by XNOR.
Simplify the expression using Boolean algebra before redrawing the circuit. In the table, 0 means false and 1 means true. A, B and C are Boolean values or expressions.
| Rule | Equivalent forms |
|---|---|
| Identity | A AND 1 = A; A OR 0 = A |
| Domination | A AND 0 = 0; A OR 1 = 1 |
| Idempotence | A AND A = A; A OR A = A |
| Complement | A AND NOT A = 0; A OR NOT A = 1 |
| Double negation | NOT NOT A = A |
| Commutative | A AND B = B AND A; A OR B = B OR A |
| Associative | (A AND B) AND C = A AND (B AND C); (A OR B) OR C = A OR (B OR C) |
| Distributive | A AND (B OR C) = (A AND B) OR (A AND C); A OR (B AND C) = (A OR B) AND (A OR C) |
| Absorption | A OR (A AND B) = A; A AND (A OR B) = A |
| De Morgan's laws | NOT (A AND B) = (NOT A) OR (NOT B); NOT (A OR B) = (NOT A) AND (NOT B) |
When applying De Morgan's laws, make both changes: switch AND with OR and invert each operand. Moving a NOT symbol inside the brackets isn't enough.
Take Z = (A AND B) OR (A AND NOT B). First construct the original circuit:
Now simplify the expression step by step:
The simplified diagram needs only a connection from A to Z. B no longer affects the output. No gates are needed for this function.
The equivalence table checks every input combination. It confirms that the original circuit and the direct connection produce identical outputs.
Equivalence of the original and simplified expressions for all input combinations.
| A | B | P = A AND B | Q = A AND NOT B | Original Z = P OR Q | Simplified Z = A |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
| A | B | P = A AND B | Q = A AND NOT B | Original Z = P OR Q | Simplified Z = A |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
A simpler diagram can use fewer gates and connections. It is valid only if the output stays unchanged for every possible input combination.
Terms to use: logic diagram, standard gate symbols, inputs, outputs, AND, OR, NOT, NAND, NOR, XOR, XNOR, Boolean algebra.