levo

Fundamentals of Data Representation

Character coding systems

  • 2 things to know
  • Paper 2

Overview

Recall questions on ASCII and Unicode, why letters are coded in alphabetical order, converting between case, and why a character code is not a numeric value.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why does the difference between a character code and a pure binary value matter in a program?

Evaluation

State one advantage and one disadvantage of Unicode compared with ASCII.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Using the digit 7, contrast how a decimal digit is held as a character with how it is held as a pure binary number.

    Model answer

    The same digit becomes two entirely different bit patterns depending on what it is meant to be. Treated as a quantity, seven is written out by place value as 111, held in a byte as 00000111, and can be added or multiplied. Treated as a printable symbol, '7' is stored as whatever number the character set assigns to that glyph — in ASCII that is 55, or 00110111 — and arithmetic on it is meaningless, because it exists only to be displayed or printed. This is why a 7 typed into a text box must be converted before it can be used in a calculation, and why in a language that concatenates text '7' + '7' yields '77' rather than 14.

  2. 2

    What are the ASCII codes of the characters '0' to '9', and how do you get from a digit to its character code?

    Model answer

    They run consecutively from 48 for '0' to 57 for '9', which is 30₁₆ to 39₁₆. The character code is therefore the digit's value plus 48, and subtracting 48 from the code recovers the numeric value — which is exactly what a conversion routine does when it turns typed text into a number.

  3. 3

    Why does the difference between a character code and a pure binary value matter in a program?

    Model answer

    Because arithmetic cannot be done on character codes directly. If '2' and '5' are typed at a keyboard the machine receives 00110010 and 00110101, two bytes of character codes, whereas the number 25 in pure binary is the single byte 00011001. Adding the two character bytes would give a meaningless answer, so input must be converted from characters to a numeric representation before it is calculated with, and converted back before it is displayed.

  4. 4

    How is text stored in a computer?

    Model answer

    Each character is replaced by the numeric code that the agreed character set gives it, and those codes are stored as a sequence of binary numbers. Nothing about the shape of the letter is stored — only its code — so the same file will display in any typeface, and the same bit pattern is only recognisable as text because the software knows to interpret it with a particular character set.

  5. 5

    Describe the ASCII coding system.

    Model answer

    ASCII is a character coding system that uses 7 bits per character, giving 2⁷ = 128 different codes. These cover the upper and lower case letters of the English alphabet, the digits 0 to 9, punctuation and a set of non-printing control characters such as carriage return and backspace. Extended versions use the eighth bit of a byte to add a further 128 codes, giving 256 in total.

  6. 6

    Are the ASCII codes for letters in alphabetical order, and why is that useful?

    Model answer

    Yes. 'A' to 'Z' run from 65 to 90 and 'a' to 'z' run from 97 to 122, each block consecutive. This means strings can be sorted alphabetically simply by comparing their character codes numerically. It also means the gap between an upper and lower case letter is a constant 32, so case can be changed by adding or subtracting 32.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A driver is .
softwarehardwarestorage

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AThe integer 5 is 0101.
B0.75 is 1/2 + 1/4.
CThe fraction bits are 1100.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Data 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.