Numeric Literals Playground

Notes on Mrs. Tini’s counter: 0xFF, 0b1010, 0o17, 2.5e3, 017 and 10n read the way code reads them, in a module and in an old script, and the way Number()…

Why it matters

Hex for colours and bytes, binary for flags, exponents for extreme numbers, _ for readability. Know every way of writing them and you can read other people’s code, and know when a leading 0 or an n changes the meaning.

The key idea

Prefixes and suffixes decide how it is read; the number stays one

Common mistakes

Try it in this playground