Skip to content

Main content

Rational Cross Product Comparison Sign

Compare two explicit integer-text rationals exactly with denominator-sign correction and no floating-point conversion.

Loading tool…

Description

Compare two exact rational numbers supplied as signed integer strings.

Number representation separates exact integer text, finite floating-point values and display spelling. Rational comparison can use exact cross products without decimal conversion, while floor/ceiling outputs still have a finite safe-integer range. Leading zeros and negative zero carry representational information that a numeric conversion or serializer can discard.

Compare two exact rational numbers supplied as signed integer strings.

When to use this tool

Use Rational Cross Product Comparison Sign when you already have firstNumeratorDecimal, firstDenominatorDecimal, secondNumeratorDecimal, secondDenominatorDecimal and need to compare two exact rational numbers supplied as signed integer strings.

How to use the tool and how it works

  1. Enter firstNumeratorDecimal, firstDenominatorDecimal, secondNumeratorDecimal, secondDenominatorDecimal. 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 comparison. Use the output convention below.

Accept optional + or - followed by 1..128 decimal digits, including leading zeros. Require both denominators nonzero; form numerator cross difference with BigInt and reverse its sign for opposite-sign denominators. Return -1, 0 or 1.1

Input fieldMeaning and unitsAccepted input
firstNumeratorDecimalFirst Numerator DecimalRequired. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
firstDenominatorDecimalFirst Denominator DecimalRequired. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
secondNumeratorDecimalSecond Numerator DecimalRequired. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
secondDenominatorDecimalSecond Denominator DecimalRequired. 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
comparisonExactly -1, 0 or 1 for the rational values; denominator signs are accounted for using exact integer cross-products.Required. Safe integer.
json
{
  "input": {
    "firstNumeratorDecimal": "1",
    "firstDenominatorDecimal": "2",
    "secondNumeratorDecimal": "2",
    "secondDenominatorDecimal": "3"
  },
  "output": {
    "comparison": -1
  }
}

Limitations and assumptions

  • Inputs are integer strings, not decimal fractions or exponent notation; no reduction is required and numeric floating-point coercion is not used.
  • 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

Use exact integer or rational arithmetic when exact large-number comparison is needed. Keep original token spelling for formatting questions, and verify that any transport or serialization step preserves distinctions such as leading zeros and negative zero.

References

  1. Calculation and input contract: number/rational-cross-product-comparison-sign — tool.io

Similar or alternative tools