Skip to content

Main content

Rational Floor Ceiling Gap Tool

Calculate rational floor ceiling gap from explicit caller-supplied inputs.

Loading tool…

Description

Use exact integer division, lower the quotient by one for a nonintegral negative ratio, and return floor and ceiling as decimal text plus gap zero for integral ratios or one otherwise.

A rational number is represented by an integer numerator and a nonzero integer denominator. Sign placement, reduction by a greatest common divisor, and the chosen division or rounding convention affect intermediate representations. Exact integer text preserves arithmetic that could be lost in a floating-point conversion.

Use exact integer division, lower the quotient by one for a nonintegral negative ratio, and return floor and ceiling as decimal text plus gap zero for integral ratios or one otherwise.

When to use this tool

Use Rational Floor Ceiling Gap when you need this particular exact fraction comparison, reduction, sign, denominator, or rounding component.

How to use the tool and how it works

  1. Enter numerator, denominator. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read floor, ceiling, gap. Use the output convention below.

Parse signed decimal-integer numerator and nonzero denominator. Use exact integer division, lower the quotient by one for a nonintegral negative ratio, and return floor and ceiling as decimal text plus gap zero for integral ratios or one otherwise.1

Input fieldMeaning and unitsAccepted input
numeratorNumerator in the numeric or exact integer-text representation declared below.Required. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
denominatorDenominator or exact integer denominator text under the stated sign restriction.Required. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
Output fieldInterpretationReturned shape
floorFloorRequired. Text; maximum UTF-16 length 8192.
ceilingCeilingRequired. Text; maximum UTF-16 length 8192.
gapCeiling minus floor: zero for an integer ratio and one otherwise.Required. Safe integer.
json
{
  "input": {
    "numerator": "-7",
    "denominator": "3"
  },
  "output": {
    "floor": "-3",
    "ceiling": "-2",
    "gap": 1
  }
}

Limitations and assumptions

  • Signed denominators are supported and gap measures ceiling-floor, not the fractional part. The tool does not produce an approximate decimal expansion or choose a rounding mode.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Reduce fractions where the interpretation requires it and choose a consistent denominator-sign and division convention. Use a complete rational operation when one denominator or determinant term is insufficient.

References

  1. Calculation and input contract: number/rational-floor-ceiling-gap — tool.io

Similar or alternative tools