Published by Patrick Mutisya · 14 days ago
In databases and spreadsheet applications you can change how numbers are shown without altering the underlying value. This is useful for readability, consistency and meeting the requirements of reports.
To set the number of decimal places you choose a format that specifies how many digits appear after the decimal point. The underlying value is unchanged; only the display is affected.
Example: The value 123.4567 displayed with two decimal places appears as 123.46.
In many tools the format code uses a period (.) followed by the required number of zeroes (0). Each zero forces a digit to be shown.
| Format Code | Result for 123.4567 |
|---|---|
| 0 | 123 |
| 0.0 | 123.5 |
| 0.00 | 123.46 |
| 0.000 | 123.457 |
Adding a currency symbol places the appropriate sign before (or after) the number. The symbol is part of the format string.
| Format Code | Result for 2500 |
|---|---|
| \$#,##0 | \$2,500 |
| £#,##0.00 | £2,500.00 |
| €0.00 | €2500.00 |
The comma (,) is a thousands separator; the number of zeroes after the decimal point controls the cents/pence displayed.
When a value represents a proportion (e.g., 0.375) you can display it as a percentage. The format multiplies the underlying value by 100 and adds the % sign.
Mathematically: \$\text{Displayed} = \text{Value} \times 100\%\$
| Format Code | Value | Result |
|---|---|---|
| 0% | 0.375 | 38% |
| 0.0% | 0.375 | 37.5% |
| 0.00% | 0.375 | 37.50% |
| Code | Meaning |
|---|---|
| 0 | Digit placeholder – displays a zero if no digit is present. |
| # | Digit placeholder – does not display extra zeros. |
| . | Decimal point. |
| , | Thousands separator. |
| $, £, € | Currency symbol. |
| % | Percentage – multiplies by 100 and adds %. |
| "text" | Literal text – appears exactly as typed. |
9876.543. Format it to show:49.9. Show how it would appear using the format code "£"#,##0.00.0.25 to a percentage format with zero decimal places.