How this site works
Methodology.
Every formula this site uses, how results are rounded, which standards are cited, and — just as importantly — what these calculators do not do.
The Formulas
Everything on the site is derived from a small set of relationships:
m = (y₂ − y₁) ÷ (x₂ − x₁)
θ = arctan(m)
grade % = m × 100
ratio = 1 : (1 ÷ |m|)
b = y₁ − m·x₁
x-intercept = −b ÷ m
d = √((x₂ − x₁)² + (y₂ − y₁)²)
midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)
perpendicular slope = −1 ÷ m
rafter = run × √(1 + (pitch ÷ 12)²)
fall per foot = (grade ÷ 100) × 12
Exact Arithmetic, Not Just Floats
Computers store decimals in binary, and most decimal fractions have no exact binary form. That is why 0.1 + 0.2 evaluates to 0.30000000000000004 in nearly every programming language, and why calculators sometimes report an intercept of −7.5×10⁻¹² where the answer is plainly zero.
To avoid this, the site converts your inputs into exact fractions wherever it can, and does the algebra in whole numbers. The slope of (1, 2) and (4, 3) is computed as 1/3 rather than 0.333…, and the y-intercept comes out as exactly 5/3. Decimals are produced at the end, for display only. Where a value cannot be represented exactly — inputs with more than ten decimal places, or numbers beyond the safe integer range — the calculator falls back to floating point and shows the decimal alone, rather than printing a fraction that is subtly wrong.
Rounding
- Slopes, intercepts and distances are shown to six decimal places.
- Angles and percent grades are shown to four.
- Reference tables use two, so columns line up.
- Feet-and-inches results are rounded to the nearest sixteenth of an inch and the fraction is reduced — 8/16 is shown as 1/2.
- Rounding happens once, at the point of display. Intermediate values are never rounded and fed into the next step, which is what causes small errors to compound.
Edge Cases
These are handled deliberately rather than left to produce whatever the arithmetic happens to give:
- Vertical lines. Reported as an undefined slope, never as infinity or a division error. The angle is given as 90°, there is no percent grade, no y-intercept, and the only equation offered is x = c.
- Identical points. Rejected with an explanation, because infinitely many lines pass through a single point. No NaN is ever displayed.
- Horizontal lines. Slope 0, no x-intercept, and no perpendicular slope — the perpendicular is vertical, so its slope is undefined.
- Negative zero. Collapsed to 0, so a result never renders as
−0. - Floating-point residue. Values that fall below one part in 10¹² of the size of the inputs are treated as zero.
Standards Cited
Where a calculator checks a result against a code, the specific clause is named on the page. Codes are amended, and local jurisdictions vary — these figures are a starting point for design, not a substitute for the code adopted where you are building.
- 2010 ADA Standards for Accessible Design, §405 Ramps — Running slope, rise per run, landing dimensions, clear width, handrail and edge-protection requirements used by the ramp calculator.
- International Plumbing Code, Table 704.1 — Minimum slope of horizontal drainage piping by pipe size — ¼″ per foot to 2½″, ⅛″ per foot for 3″ to 6″, 1/16″ per foot for 8″ and larger.
- Uniform Plumbing Code, §708.0 — The alternative minimum-slope schedule, offered alongside the IPC because the two disagree at 3″ pipe and jurisdictions adopt one or the other.
What These Calculators Do Not Do
Being explicit about the limits is more useful than implying there are none:
- The ramp calculator is not an inspection. It checks the geometry described in §405 — slope, rise, landings, footprint. It cannot assess surface finish, edge protection, handrail construction or the route leading to the ramp.
- The rafter length is a theoretical line length. It excludes overhang, ridge-board deduction, plumb cuts and the birdsmouth, all of which depend on framing details this site does not ask for.
- Pipe sizing is out of scope. The pipe calculator checks slope only. Fixture-unit loading, venting and pipe diameter selection are separate calculations.
- Only straight lines. Slope here always means the slope of a line. The slope of a curve at a point is a derivative, which needs calculus rather than two coordinates.
How the Maths Is Checked
The calculation engine has an automated test suite of over a hundred and seventy assertions covering textbook cases, published standards and every edge case listed above. The expected values were derived independently — by hand, or from the source standard — rather than recorded from the code's own output, which would only prove the code agrees with itself.
Reference tables are generated by the same engine that powers the calculators rather than typed in, so a table and a calculator on this site cannot disagree.
Corrections
If you find a wrong answer, a misquoted standard or a case that is handled badly, it is worth reporting — an error in a calculator is worse than no calculator. Formulas and cited standards were last reviewed on .