acalculator

What class width do I use?

Type the smallest and largest values in your data and how many classes you want. The class width calculator gives the width for a frequency table or histogram, rounded up so that no data value falls on a class boundary, with the starting point of the first class.

Your numbers

Class width
2

With 8 classes from 60 to 74, use a class width of 2.

Width before rounding
1.7625
Range ÷ number of classes
1.75
Range
14
Starting point
59.95
Ending value
74.05
Last class ends at
75.95

Class width: 2. With 8 classes from 60 to 74, use a class width of 2.

How to calculate

Finds the class width for a frequency table or histogram from the smallest and largest data values and the number of classes, rounded up so that no value falls on a class boundary.

Example with the default inputs (Smallest data value 60, Largest data value 74, Number of classes 8, Decimal places in the data 1, Round the width up to a multiple of 1): With 8 classes from 60 to 74, use a class width of 2.

Method: Starting point = smallest − ½ × 10^−d; ending value = largest + ½ × 10^−d (d = decimal places in the data); width before rounding = (ending value − starting point) ÷ classes; class width = that width rounded up to a multiple of the step.

  • Classes have equal widths and start at the starting point, half a data unit below the smallest value, so no data value falls on a boundary.
  • A width that is already a multiple of the rounding step is kept as it is.
  • The suggested number of classes is √n rounded to the nearest whole number, a guideline some authors follow.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Smallest data value 60, Largest data value 74, Number of classes 8, Decimal places in the data 1, Round the width up to a multiple of 1 gives Starting point 59.95, Ending value 74.05, Width before rounding 1.7625, Class width 2, Range ÷ number of classes 1.75, Range 14, Last class ends at 75.95.Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18)
  2. Smallest data value 1, Largest data value 6, Number of classes 6, Decimal places in the data 0, Round the width up to a multiple of 1 gives Starting point 0.5, Ending value 6.5, Width before rounding 1, Class width 1, Last class ends at 6.5.Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18)
  3. Smallest data value 10, Largest data value 50, Number of classes 4, Decimal places in the data 0, Round the width up to a multiple of 1, Number of data values (optional) 150 gives Width before rounding 10.25, Class width 11, Range ÷ number of classes 10, Starting point 9.5, Last class ends at 53.5, Suggested number of classes (√n) 12.Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18) (150 values: √150 ≈ 12.25, so 12 bars)
  4. Smallest data value 2.13, Largest data value 9.87, Number of classes 5, Decimal places in the data 2, Round the width up to a multiple of 0.1 gives Starting point 2.125, Ending value 9.875, Width before rounding 1.55, Class width 1.6, Last class ends at 10.125.Source: OpenStax, Introductory Statistics 2e, §2.2 Histograms, Frequency Polygons, and Time Series Graphs (Example 2.7: start 60 − 0.05 = 59.95, end 74 + 0.05 = 74.05, (74.05 − 59.95) ÷ 8 = 1.76, rounded up to 2; Example 2.8: 0.5 to 6.5 in 6 bars of width 1; about √n bars), https://openstax.org/books/introductory-statistics-2e/pages/2-2-histograms-frequency-polygons-and-time-series-graphs (retrieved 2026-10-18)

How it works

Let d be the most decimal places any data value has (0 for whole numbers), so a data unit is 10^−d (1 for whole numbers, 0.1 for one decimal place) and half a unit is ½ × 10^−d.

  1. Starting point = smallest value − ½ × 10^−d.
  2. Ending value = largest value + ½ × 10^−d.
  3. Width before rounding = (ending value − starting point) ÷ number of classes.
  4. Class width = the width before rounding, rounded up to the next whole multiple of the rounding step (1 by default). A width that is already a multiple of the step is kept.

The page also shows:

  • Range = largest − smallest, and range ÷ number of classes, the short formula many books use before rounding up.
  • Last class ends at = starting point + number of classes × class width. It is above the largest value, so the classes hold every value.
  • Suggested number of classes = √n rounded to the nearest whole number, when you type the number of data values n (a whole number from 1 to 1,000,000,000).

Rules. The smallest and largest values are from −10¹² to 10¹², and the largest may not be below the smallest (then there is no answer). The number of classes is a whole number from 1 to 1,000; decimal places from 0 to 6; the rounding step is above 0. Typed values are read as exact decimals, so every step is exact.

Output format. Numbers show up to 10 decimal places (trailing zeros dropped), with thousands separators. The suggested number of classes is a whole number.

Worked examples by hand

Soccer players’ heights (OpenStax Example 2.7). Smallest 60, largest 74, one decimal place, 8 classes. Starting point 60 − 0.05 = 59.95; ending value 74 + 0.05 = 74.05. Width (74.05 − 59.95) ÷ 8 = 14.1 ÷ 8 = 1.7625, rounded up to 2. The last class ends at 59.95 + 8 × 2 = 75.95. The short formula gives 14 ÷ 8 = 1.75.

Books bought (OpenStax Example 2.8). Whole numbers from 1 to 6 in 6 classes. Starting point 0.5, ending value 6.5; (6.5 − 0.5) ÷ 6 = 1, already a whole number, so the class width is 1.

Whole numbers from 10 to 50 in 4 classes. Starting point 9.5, ending value 50.5; 41 ÷ 4 = 10.25, rounded up to 11. The last class ends at 9.5 + 44 = 53.5. With 150 data values, √150 ≈ 12.25, so about 12 classes.

Two decimals, rounded up to a tenth. Smallest 2.13, largest 9.87, 5 classes, step 0.1. Starting point 2.125, ending value 9.875; 7.75 ÷ 5 = 1.55, rounded up to 1.6. The last class ends at 2.125 + 5 × 1.6 = 10.125.

Other questions people ask

How do I calculate class width?

Start half a data unit below the smallest value and end half a unit above the largest. Divide that span by the number of classes, then round up. For heights from 60 to 74 inches recorded to one decimal place, in 8 classes: (74.05 − 59.95) ÷ 8 = 1.7625, so use a width of 2.

Why is the class width rounded up?

Rounding up makes the classes cover all the data with a little to spare. With the starting point half a unit below the smallest value and a width that is a whole number of data units, every class boundary falls between data values, so no value sits on a boundary.

Why not just divide the range by the number of classes?

(Largest − smallest) ÷ classes is the short formula, and the page shows it too. If it divides exactly, the largest value lands on the top boundary of the last class. Adding half a unit at each end avoids that: whole numbers from 10 to 50 in 4 classes need a width of 11, not 10.

How many classes should I use?

Many histograms have 5 to 15 classes. One guideline is the square root of the number of data values, rounded to the nearest whole number: 150 values suggest 12 classes. Type the number of values to see the suggestion.

What starting point should I use?

Use the smallest value minus half a data unit: 59.95 for data with one decimal place and a smallest value of 60, or 0.5 for whole numbers starting at 1. The first class runs from the starting point to the starting point plus the class width.

What if my data have decimals?

Set the number of decimal places in the data. Values such as 61.5 have one, so the half unit is 0.05. You can also round the width up to a tenth or another step instead of a whole number.