Description
Return representative=residue-modulus when residue>modulus/2, or when exactly halfway and positiveTie=false; otherwise preserve the residue.
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 representative=residue-modulus when residue>modulus/2, or when exactly halfway and positiveTie=false; otherwise preserve the residue.
When to use this tool
Use Modular Signed Residue Representative when you need this exact stated integer sign, bound, division, comparison, or factor component.
How to use the tool and how it works
- Enter integer, modulus, positiveTie. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read representative. Use the output convention below.
For positive integer modulus reduce integer to a nonnegative residue. Return representative=residue-modulus when residue>modulus/2, or when exactly halfway and positiveTie=false; otherwise preserve the residue.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| integer | Safe integer number or exact signed decimal-integer text as declared below. | Required. Safe integer. |
| modulus | Modulus | Required. Safe integer; minimum 1. |
| positiveTie | Choose the positive half-modulus representative at an even-modulus tie. | Required. Boolean. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| representative | Representative | Required. Safe integer. |
{
"input": {
"integer": 7,
"modulus": 10,
"positiveTie": true
},
"output": {
"representative": -3
}
} Limitations and assumptions
- The midpoint policy matters only for an even modulus. This numeric representative calculation is bounded by the safe-integer contract and does not produce an exact arbitrary-size integer string.
- 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.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
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
Similar or alternative tools
- Number: Modulus Symmetric Representative
Return the exact symmetric residue in [-m/2,m/2), choosing the negative representative at even-modulus ties.
- Rational Signed Denominator Crossproduct Order
Compare left=a*d and right=c*b using exact integer arithmetic, then reverse the comparison if the denominator signs differ; return order=-1,0,1 for first fraction versus second.