liveBook · Manning

Numeric base

As explained in JavaScript in Depth

The base of a positional numeral system whose powers determine the place values of digits.

Why can a byte hold 256 values but only reach 255? A numeric base, or radix, sets the place values of its digits. Counting from the right, each position is a successive power of the base, beginning with power zero. section 3.1.1

In decimal, 1234 means 1×10³ + 2×10² + 3×10¹ + 4×10⁰. Binary uses the same rule with powers of 2. Eight binary positions yield 2⁸ = 256 patterns; because zero occupies one pattern, unsigned values run from 0 to 255. Two’s complement gives those patterns a different, signed interpretation. section 3.1.1

Binary: 1011 = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11 in decimal

Read each binary digit against its power of 2 to see why 1011 has decimal value 11. section 3.1.1

How JavaScript in Depth covers it

How deep it goes
Works through decimal and binary place values and eight-bit capacity, without developing arbitrary-base conversion.
Examples
Expands 1234 in decimal and 1011 in binary, then counts the 256 patterns of an eight-bit byte.
What it assumes
Builds from concrete decimal and binary expansions rather than assuming familiarity with number encoding.
What you can do after
Evaluate/understand binary place values and calculate how many unsigned values a given number of bits represents.
How it connects
Links positional notation to bits, bytes, unsigned integers, and two’s complement.

Also explained in

Compare how 3 books explain numeric base →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.