Description
Return exact shifted integer and signed-range margin.
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 exact shifted integer and signed-range margin.
When to use this tool
Use Signed Shift Overflow Margin when evaluating the stated shift, arithmetic flag or rounding convention.
How to use the tool and how it works
- Enter value, shift, width. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read shiftedDecimal, marginDecimal, fits. Inspect fits before interpreting the associated values.
Return exact shifted integer and signed-range margin. Require width 1..53, shift 0..53 and signed in-range value; shift exactly, margin is upper-value when nonnegative or value-lower otherwise, fits means margin >= 0.1
Fixed-width signed conversion first reduces modulo two to the word width, then interprets values in the upper half as negative.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| value | Value | Required. Safe integer. |
| shift | Shift | Required. Safe integer; minimum 0; maximum 53. |
| width | Width under the stated bit, interval or geometry convention; apply the field-specific units and bounds. | Required. Safe integer; minimum 1; maximum 53. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| shiftedDecimal | Shifted Decimal | Required. Text; maximum UTF-16 length 8192. |
| marginDecimal | Margin Decimal | Required. Text; maximum UTF-16 length 8192. |
| fits | Whether calculated use is no greater than the supplied limit. | Required. Boolean. |
{
"input": {
"value": 30,
"shift": 2,
"width": 8
},
"output": {
"shiftedDecimal": "120",
"marginDecimal": "7",
"fits": true
}
} Limitations and assumptions
- A negative decimal margin reports overflow; the shifted value is not saturated or wrapped.
- 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
-
Calculation and input contract: bitwise/signed-shift-overflow-margin — tool.io
-
BigInt fixed-width signed and unsigned conversion — Ecma International, TC39
Similar or alternative tools
- Signed Shift Overflow Witness
Return an exact signed left shift and a wrapping witness.
- Word Funnel Shift Single Lane
Return a low-width lane from a two-word funnel shift.