Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem
Computer ScienceComputer Science PrinciplesHigh school

Binary and Data

Number bases, bits, bytes and compression.

Computers store everything, from numbers to photos to this sentence, as patterns of bits, each 0 or 1. Binary is base 2: each place is worth a power of two, so 10112=8+0+2+1=111011_2 = 8 + 0 + 2 + 1 = 11. Eight bits make a byte, which can hold 28=2562^8 = 256 different values.

Hexadecimal (base 16) is a compact way to write binary, with each hex digit standing for exactly four bits. Text is stored using codes such as ASCII and Unicode, images as grids of pixel colour values, and compression shrinks data either losslessly (every bit recoverable) or lossily (some detail discarded).

Key terms

Binary place value
Each place is a power of two.
10112=8+0+2+1=111011_2 = 8 + 0 + 2 + 1 = 11

Key ideas

  • nn bits can represent 2n2^n distinct values.
  • Convert decimal to binary by repeatedly dividing by 2 and reading remainders upward.
  • Hex digits: 0-9 then A-F for 10-15; FF16=255\text{FF}_{16} = 255.
  • Overflow happens when a result needs more bits than are available.

Worked example

Convert 4545 to binary and to hexadecimal.

  1. 45=32+8+4+145 = 32 + 8 + 4 + 1.
  2. Binary: 1011012101101_2.
  3. Group four bits from the right: 0010  11010010\;1101.
  4. Hex: 2D162\text{D}_{16}.

Answer: 1011012=2D16101101_2 = 2\text{D}_{16}

Common mistakes

  • Reading remainders top-down instead of bottom-up.
  • Forgetting that counting starts at 0, so 8 bits reach 255, not 256.
  • Assuming lossy compression can be fully undone.

Practice questions

Try each one, then open the answer. Numerical answers on this page are verified by an automated calculation check.

  1. 1.Convert 11010211010_2 to decimal.

    Show answer

    2626

  2. 2.How many values can 10 bits represent?

    Show answer

    10241024

  3. 3.Convert 3F16\text{3F}_{16} to decimal.

    Show answer

    6363

More in Computer Science Principles