Skip to content

Main content

Signed Magnitude Add Sign Conflict Tool

Compute signed magnitude add sign conflict from explicit bounded inputs.

Loading tool…

Description

Compare signed-magnitude operands for opposing nonzero signs.

A fixed-width bit pattern and the number it represents are different concepts. Unsigned, two's-complement, one's-complement, sign-magnitude and biased encodings use different sign and zero conventions, so a bit-preserving transformation need not preserve numerical meaning.

Compare signed-magnitude operands for opposing nonzero signs.

When to use this tool

Use Signed Magnitude Add Sign Conflict when checking the stated fixed-width representation or encoding convention.

How to use the tool and how it works

  1. Enter leftSign, leftMagnitude, rightSign, rightMagnitude. 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 conflict, cancel, dominantSign. Inspect conflict, cancel, dominantSign before interpreting the associated values.

Compare signed-magnitude operands for opposing nonzero signs. Parse nonnegative exact magnitude strings; conflict requires different sign flags and both magnitudes nonzero, cancel additionally equal magnitudes; dominantSign selects the larger magnitude's flag or false for equal magnitudes.1

Input fieldMeaning and unitsAccepted input
leftSignLeft SignRequired. Boolean.
leftMagnitudeLeft MagnitudeRequired. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
rightSignRight SignRequired. Boolean.
rightMagnitudeRight MagnitudeRequired. 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
conflictConflictRequired. Boolean.
cancelCancelRequired. Boolean.
dominantSignFalse whenever magnitudes are equal, even if both supplied signs are negative; otherwise the larger magnitude's sign.Required. Boolean.
json
{
  "input": {
    "leftSign": true,
    "leftMagnitude": "5",
    "rightSign": false,
    "rightMagnitude": "3"
  },
  "output": {
    "conflict": true,
    "cancel": false,
    "dominantSign": true
  }
}

Limitations and assumptions

  • Equal magnitudes return false even for equal sign flags; this is not a full addition result or an unambiguous sign when tied.
  • 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

Choose an explicit representation and width, validate the complete encoded value and use the matching signed or unsigned conversion for the intended numerical interpretation.

References

  1. Calculation and input contract: bitwise/signed-magnitude-add-sign-conflict — tool.io

Similar or alternative tools