Skip to content

Main content

Signed Shift Overflow Witness Tool

Exact signed left-shift witness using an explicit two-complement width.

Loading tool…

Description

Return an exact signed left shift and a wrapping witness.

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.

Return an exact signed left shift and a wrapping witness.

When to use this tool

Use Signed Shift Overflow Witness when evaluating the stated shift, arithmetic flag or rounding convention.

How to use the tool and how it works

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

Return an exact signed left shift and a wrapping witness. Require width 1..53, shift 0..8192 and value inside the signed width range; exactDecimal is the BigInt shift, wraps tests range, wrapped uses signed width truncation.1

Fixed-width signed conversion first reduces modulo two to the word width, then interprets values in the upper half as negative.2

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 1; maximum 53.
shiftShiftRequired. Safe integer; minimum 0; maximum 8192.
Output fieldInterpretationReturned shape
exactDecimalExact decimal integer text before fixed-width wrapping; retain text for full precision.Required. Text; maximum UTF-16 length 8192.
wrapsWrapsRequired. Boolean.
wrappedWrappedRequired. Safe integer.
json
{
  "input": {
    "value": 60,
    "width": 8,
    "shift": 2
  },
  "output": {
    "exactDecimal": "240",
    "wraps": true,
    "wrapped": -16
  }
}

Limitations and assumptions

  • Exact text can exceed machine-word range; wrapped is a numeric two's-complement result and no language/hardware overflow behavior is executed.
  • 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-shift-overflow-witness — tool.io

  2. BigInt fixed-width signed and unsigned conversion — Ecma International, TC39

Similar or alternative tools