Math calculator

Floor and Ceiling Calculator

Down, up, and towards zero — which are not the same.

Down, up, or towards zero

All three at once, because for negatives they differ.

⌊−2.5⌋ and ⌈−2.5⌉

−3 and −2

Truncation gives −2, not −3. For a negative number, cutting the decimal off moves the value UP, and flooring moves it down.

Floor ⌊x⌋

−3

down, towards −∞

Ceiling ⌈x⌉

−2

up, towards +∞

Truncate

−2

towards zero — not the same as floor

Nearest integer

−3

halves away from zero

Fractional part

0.5

measured up from the floor

  • Floor and truncation disagree here. Flooring goes down to −3; truncation cuts the decimal off and gives −2, which is upward for a negative number.
  • The value sits exactly halfway between two integers, so the nearest integer depends on a convention rather than on the arithmetic.
  • Ceiling is the mirror of floor: ⌈x⌉ = −⌊−x⌋, which is why −2.5 ceilings to −2.

What this tool shows

For positive numbers, flooring and truncating agree and nobody notices the difference. For negative numbers they do not: ⌊−2.5⌋ is −3 and truncating gives −2. Both are shown here on every input.

  • Floor, ceiling and truncation of any value
  • Why they differ for negative numbers
  • The nearest integer, and its convention
  • Floored and truncated integer division
  • Which remainder sign each produces
  • Where Python and C disagree
Floor, ceiling, truncate The negative trap Exact on decimals Two division conventions

Switch to integer division for the same split applied to a quotient.

Updated 7 September 2026 · Works in any browser, no installation

Floor rounds down, ceiling rounds up, and truncation cuts towards zero. For positive numbers floor and truncation agree, so most people never separate them. For negative numbers they do not: ⌊−2.5⌋ is −3 and truncating −2.5 gives −2.

At a glance

Formula shown
⌊x⌋ is the greatest integer not above x; ⌈x⌉ is the least integer not below it. Truncation discards the fractional part, which equals the floor for x ≥ 0 and the ceiling for x < 0. The two are linked by ⌈x⌉ = −⌊−x⌋.
Scenario support
Working out how many boxes a quantity needs; finding which page an item falls on; converting a measurement down to whole units; deciding a remainder sign in code.
Educational estimate
Planning support from the values you enter — not professional advice.

Three operations, not one

Floor goes down, always. Towards −∞, whatever the sign.

Ceiling goes up, always. Towards +∞.

Truncation goes towards zero, which means down for positives and up for negatives. It is what happens when you cut the decimal part off and keep the digits.

Rounding to nearest is a fourth thing again, and the only one of the four that needs a tie-breaking rule — which is why 2.5 is a question and 2.4 is not.

Where they disagree

Take −2.5. Flooring goes down to −3. Truncating cuts the .5 off and leaves −2, which is upward.

For every positive number they agree, so the difference is invisible in testing until a negative arrives. That is what makes it a bug rather than a mistake: the code works, then one day a value goes below zero.

The magnitude of the gap is not the issue — both answers are within one. The issue is the direction, and the fact that a total built out of many such steps drifts consistently one way.

Worth remembering: ⌊−0.0001⌋ is −1. A value a hair below zero floors a whole unit down, which surprises people the first time.

The identity that links them

⌈x⌉ = −⌊−x⌋. Ceiling is floor viewed in a mirror.

It is worth knowing because it means you only ever need one of the two. A language that gives you a floor gives you a ceiling for free, and a rounding routine written once handles both directions.

It also explains the asymmetry cleanly. Flooring and truncating agree on positives because truncation IS flooring there; they disagree on negatives because truncation becomes the ceiling instead. Truncation is not a third direction — it is floor and ceiling stitched together at zero.

Integer division inherits the split

Divide −7 by 2 in whole numbers and there are two defensible answers.

Floored: −4 remainder 1. The remainder is non-negative, and it takes the sign of the divisor.

Truncated: −3 remainder −1. The remainder takes the sign of the dividend.

Both satisfy dividend = quotient × divisor + remainder, so neither is wrong. Python floors; C, Java and JavaScript truncate. A routine ported between them changes its answer on exactly this input, and the symptom is usually an array index going negative.

If you only ever want a non-negative remainder — which is what a clock, a hash bucket or a ring buffer wants — the floored convention is the one that gives it without a correction step.

Where it gets used

Counting containers. Twelve items into boxes of five needs ⌈12/5⌉ = 3 boxes. Flooring would say two, and two boxes do not hold twelve items.

Paging. Which page item 12 falls on, with ten per page, is a flooring question. How many pages there are in total is a ceiling one. Getting them the wrong way round is the classic off-by-one.

Time and dates. Turning seconds into whole minutes floors; working out how many minutes a task will occupy ceilings.

Graphics and layout. Snapping a coordinate to a pixel grid floors, and a half-pixel offset is why a hairline border sometimes disappears.

Sources and methodology

The notation and the conventions are standard; these are the references.

Method. Floor and ceiling are computed on exact rationals parsed from the digits you type, not on a double, so the answer never depends on whether a decimal happens to be representable in binary. That matters more than it sounds: flooring a value that is a hair below an integer in floating point returns the integer below it, and 0.1 + 0.2 is famously such a value. Integer division is computed on BigInt in both conventions at once, and both are checked to reconstruct the dividend. That engine is verified on every change against 140 hand-written assertions, including that floor ≤ x ≤ ceiling with a gap of exactly one for every non-integer, checked across three thousand generated values, and that the identity ceil(x) = −floor(−x) holds on two thousand more. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

RoundingAll seven rounding rules on the same number at once, so the disagreement at a tie is visible rather than buried inside whichever one your software happened to pick.
ModuloAll three conventions at once, because −7 mod 3 is −1 in JavaScript and 2 in Python and a page that gives only one of those is wrong for half its readers.
Significant FiguresMarks each digit significant or not with the reason, reports when the notation is genuinely ambiguous, and applies the different rules for multiplying and for adding.
Absolute ValueAbsolute value as a distance from zero — plus the distance between two numbers, and a relative change from zero reported as undefined rather than as infinity.
Digital RootEvery round of digit addition shown, with the mod-9 shortcut alongside — and a casting-out-nines checker that will show you a wrong sum passing.
Consecutive IntegersThe run that sums to your target, or the reason there is not one — plus every run a number admits, and why the powers of two admit none.

More in Math, or browse all calculators.

Read the guide

For the three remainder conventions in full — floored, truncated and Euclidean — the Modulo Calculator covers the same split from the other direction.

Educational use disclaimer

This is an educational tool. Values are read from the digits you type and floored exactly, so the result does not depend on how a decimal happens to be stored.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (3 updates)

Published 7 September 2026

  1. Published the floor and ceiling page showing truncation alongside both, since floor and truncation agree on every positive number and disagree on every negative one — which is what makes the confusion a bug rather than a mistake.
  2. Carries the same split into integer division, where it decides the sign of the remainder: Python floors and C, Java and JavaScript truncate, so a routine ported between them changes its answer on −7 ÷ 2.
  3. Computed on exact rationals parsed from the digits typed, so flooring never depends on whether a decimal happens to be representable in binary.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.