CS core subjects

Stage 1 · Lesson 2 of 7

Text encodings and floating point

How a computer runs a program

Characters are stored as numbers too. , an early scheme, gives 128 characters a number each, which fits in 7 . Unicode goes much further.

It gives every character in every script its own number, called a . UTF-8 is the usual way to store those code points, using one to four per character. Numbers with a fractional part are stored as , following a standard called IEEE 754.

Each number is kept as a sign, an exponent (the scale) and a fraction (the digits). Most decimal fractions cannot be stored exactly this way. That is why 0.1 + 0.2 is not exactly 0.3 in most languages. It is also why money is stored as whole cents or as a decimal type.

Common trapassuming one character is one byte, which breaks string lengths, database column sizes and file parsing as soon as someone types Urdu, Arabic or an emoji.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

Keep handy

  • A topic map of the whole CS curriculum to check your coverage against, stage by stage

  • Short explanations from researchers when one idea, such as floating point, will not click

Also worth your time

Mark this stage as not done?