Be able to format numerical values to a specified number of decimal places
📊 16 Graphs and Charts – Formatting Numbers
Objective
Be able to format numerical values to a specified number of decimal places.
Why Do We Format Numbers?
When we show data in graphs or tables, too many decimal places can make the chart look messy and hard to read. Formatting is like trimming a messy haircut – you keep just enough detail to understand the trend, but nothing extra that distracts.
Common Ways to Format Numbers
- Spreadsheet Functions –
ROUND,ROUNDUP,ROUNDDOWN - Programming Languages –
format()in Python,toFixed()in JavaScript - Charting Tools – Built‑in number‑format options in Excel, Google Sheets, or data‑visualisation libraries.
Spreadsheet Example (Excel / Google Sheets)
Suppose we have the raw value 3.1415926535. We want it to show only 2 decimal places.
| Original Value | Formula | Formatted Value |
|---|---|---|
| 3.1415926535 | =ROUND(3.1415926535, 2) | 3.14 |
| 2.71828 | =ROUNDUP(2.71828, 1) | 2.8 |
| 1.9999 | =ROUNDDOWN(1.9999, 0) | 1 |
Using LaTeX to Show Rounding Rules
When we round a number, we look at the digit immediately after the place we want to keep.
- If that digit is 5 or more, we increase the last kept digit by 1.
- If it is less than 5, we leave the last kept digit unchanged.
Example: 7.653 rounded to two decimal places:
$7.653 \;\xrightarrow{\text{keep two places}}\; 7.65$ (since the third digit 3 < 5, we keep 5).
Example: 7.658 rounded to two decimal places:
$7.658 \;\xrightarrow{\text{keep two places}}\; 7.66$ (since the third digit 8 ≥ 5, we increase 5 to 6).
Practical Exercise
- Open a new spreadsheet.
- Enter the following raw values in column A: 12.3456, 0.9876, 123.456.
- In column B, use
ROUND(A1, 2)and drag down. - In column C, use
ROUNDUP(A1, 1)and drag down. - In column D, use
ROUNDDOWN(A1, 0)and drag down. - Compare the results and notice how each function behaves.
Quick Reference Cheat Sheet
| Function | Purpose | Example |
|---|---|---|
| ROUND | Rounds to nearest value. | =ROUND(2.345, 1) → 2.3 |
| ROUNDUP | Always rounds away from zero. | =ROUNDUP(2.345, 1) → 2.4 |
| ROUNDDOWN | Always rounds toward zero. | =ROUNDDOWN(2.345, 1) → 2.3 |
Remember
Formatting numbers is all about making data clear and readable. Think of it as choosing the right font size for a headline – too small and you miss details, too big and you lose focus.
Try formatting the numbers in your next graph or chart and notice how the visual story changes!
Revision
Log in to practice.