2.675 Rounds Down Because It Was Never 2.675
Published 12/2/2026 · 3 min read · Developer tools
Daniel Okonkwo — Front-end developer and tech writer at OneKitly
Web performance · File formats
Checked against 2 sources
Binary floating point cannot represent most decimal fractions exactly, in the same way base ten cannot write a third. The literal 2.675 becomes the nearest available double, which is 2.674999999999999822364316059975, and every operation afterwards works on that value. Rounding it to two decimals therefore rounds a number that is genuinely below the halfway point, and the answer is 2.67. The tool prints the floor, the ceiling and both half-up and half-even results side by side precisely so this disagreement is visible instead of surprising.
Stored as a double it is 2.674999999999999822…, so rounding to two decimals gives 2.67. The same happens to 1.005 and 8.475.
Half-even exists to stop a bias, not to be clever
Always rounding halves upward adds a small positive bias to every sum, and over a million transactions that bias is money. Rounding halves to the nearest even number sends them up and down in equal measure, which is why accounting standards and the IEEE floating-point standard both default to it. The cost is that 2.5 becomes 2 and 3.5 becomes 4, which looks wrong to anyone taught the school rule, and the tool shows both so the difference can be checked rather than argued about.
Money should not be held in floating point at all
The fix for prices is to stop using fractions of a currency unit and to count the smallest unit as an integer: store 267 cents rather than 2.67, and do every calculation in cents. Databases offer a decimal type for the same reason, and financial libraries offer arbitrary-precision decimals where percentages and interest are involved. Floating point is excellent for physics, where a relative error of one part in ten thousand billion is irrelevant, and wrong for a ledger that must balance exactly.
| Typed | Stored | Rounded to 2 decimals |
|---|---|---|
| 2.675 | 2.67499999999999982… | 2.67 |
| 1.005 | 1.00499999999999989… | 1.00 |
| 8.475 | 8.47499999999999964… | 8.47 |
| 0.1 + 0.2 | 0.30000000000000004… | 0.30, but not equal to 0.3 |
Worked with our own calculator
Ceiling and floor function calculator
Given
- Number
- 7.4
Result
- Ceiling ⌈x⌉
- 8
- Floor ⌊x⌋
- 7
- Rounded
- 7
- Truncated
- 7
- Fractional part
- 0.4
These figures are produced by the calculator below, not typed in by hand — they are recomputed whenever the tool changes.
Run it on your own figures →Frequently asked questions
- Why does 0.1 + 0.2 not equal 0.3?
- Because neither 0.1 nor 0.2 exists exactly in binary, so their sum is the nearest double to a slightly wrong total: 0.30000000000000004. Printing it shows 0.3 because the display rounds, and comparing it with 0.3 returns false because the comparison does not. The habit that avoids the whole family of bugs is to compare with a tolerance, or to work in integers where exactness matters.
- How do floor and ceiling behave on negatives?
- Floor always goes towards minus infinity and ceiling always towards plus infinity, so the floor of −3.7 is −4 and its ceiling is −3. Truncation is a third operation that simply removes the decimals and therefore goes towards zero, giving −3 — which is why integer division in some languages disagrees with the mathematical floor on negative numbers, and why a modulo can come out negative where a mathematician expects it not to.
Articles you may find interesting
All guides →Related tools
Sources
Spotted a mistake in this article?