Skip to content

Main content

Signed Saturation Clamp Boundary Tool

Calculate signed saturation clamp boundary from explicit caller-supplied inputs.

Loading tool…

Description

Clamp a supplied integer to a signed word range.

Fixed-width arithmetic can wrap, saturate, shift in sign bits or expose discarded bits. Carry, borrow and signed overflow describe different conditions; a local rounding decision or guard/sticky triplet is one part of an arithmetic operation rather than a complete floating-point result.

Clamp a supplied integer to a signed word range.

When to use this tool

Use Signed Saturation Clamp Boundary when evaluating the stated shift, arithmetic flag or rounding convention.

How to use the tool and how it works

  1. Enter value, width. 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 value, saturated. Inspect saturated before interpreting the associated values.

Clamp a supplied integer to a signed word range. Require width 2..32; lower = -2^(width-1), upper = 2^(width-1)-1, value clamps to those bounds and saturated reports any change.1

Input fieldMeaning and unitsAccepted input
valueValueRequired. Safe integer.
widthWidth under the stated bit, interval or geometry convention; apply the field-specific units and bounds.Required. Safe integer; minimum 2; maximum 32.
Output fieldInterpretationReturned shape
valueValueRequired. Safe integer.
saturatedSaturatedRequired. Boolean.
json
{
  "input": {
    "value": 200,
    "width": 8
  },
  "output": {
    "value": 127,
    "saturated": true
  }
}

Limitations and assumptions

  • This is signed saturation rather than modular truncation or detection of a preceding arithmetic operation.
  • 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 a complete arithmetic operation with explicit width, signedness, overflow and rounding policy; keep exact integer text when values exceed ordinary numeric precision.

References

  1. Calculation and input contract: bitwise/signed-saturation-clamp-boundary — tool.io

Similar or alternative tools