Skip to content

Main content

Number: Modulus Symmetric Representative Tool

Return the exact symmetric residue in [-m/2,m/2), choosing the negative representative at even-modulus ties.

Loading tool…

Description

Return the exact symmetric residue in [-m/2,m/2), choosing the negative representative at even-modulus ties.

Exact integer arithmetic and finite numeric arithmetic have different range limits. A safe integer number is bounded by +/-9007199254740991, while supported decimal-integer text can represent larger values. Division and remainder also need a signed convention: truncating quotients and Euclidean nonnegative remainders can give different results.

Return the exact symmetric residue in [-m/2,m/2), choosing the negative representative at even-modulus ties.

When to use this tool

Use Number: Modulus Symmetric Representative when you need this exact stated integer sign, bound, division, comparison, or factor component.

How to use the tool and how it works

  1. Enter integer, modulus. 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 result. Expand result to inspect the returned fields.

Parse signed integer text and a positive modulus, reduce to a nonnegative residue, then return residue-modulus when twice the residue>=modulus, otherwise residue. Return representative as exact decimal text inside result.1

Input fieldMeaning and unitsAccepted input
integerSafe integer number or exact signed decimal-integer text as declared below.Required. Text. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
modulusModulusRequired. Text. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
Output fieldInterpretationReturned shape
resultObject containing the calculated result members described below.Required. Object.
result.representativeExact symmetric residue text with negative halfway tie.Calculated result member: string.
json
{
  "input": {
    "integer": "8",
    "modulus": "10"
  },
  "output": {
    "result": {
      "representative": "-2"
    }
  }
}

Limitations and assumptions

  • For an even modulus the exact halfway residue maps to the negative representative. This fixed tie policy differs from choosing a positive midpoint and does not infer the convention required by another application.
  • Outputs are nested inside result. 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 decimal-integer tools when the range exceeds safe numeric integers. State the division, remainder, midpoint, and zero convention before combining results from different operations.

References

  1. Calculation and input contract: number/modulus-symmetric-representative — tool.io

Similar or alternative tools

  • Modular Signed Residue Representative

    Return representative=residue-modulus when residue>modulus/2, or when exactly halfway and positiveTie=false; otherwise preserve the residue.

  • Signed Remainder Convention Residual

    Return truncatedRemainder=dividend%divisor using truncation toward zero, euclideanRemainder=(r+abs(divisor)) modulo abs(divisor), and residual=truncated-euclidean, all as decimal strings.