Bitfield Mask Integer String
Build an exact arbitrary-width bitfield mask as a decimal integer string; zero width has a zero mask.
Description
Build an exact arbitrary-width bitfield mask as a decimal integer string; zero width has a zero mask.
A contiguous bit mask is determined by a least-significant-bit-based offset and a width.
When to use this tool
Build an exact arbitrary-width bitfield mask as a decimal integer string; zero width has a zero mask.
- Prepare the supplied offset, width fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter offset, width. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.mask. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require each offset and width from 0 to 2,048. Return ((2^width)-1) shifted left offset as decimal integer text.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| offset | offset. | Integer from 0 to 2048 inclusive |
| width | width. | Integer from 0 to 2048 inclusive |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.mask | The mask value under the stated formula or text convention. |
{
"input": {
"offset": 3,
"width": 2
},
"output": {
"result": {
"mask": "24"
}
}
} Limitations and assumptions
- Zero width returns zero. Offset and width are independently bounded; no enclosing word width or field collision check is applied.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Lists are limited to 128 entries. JSON text must meet bounded size and depth checks, and numeric outputs beyond the safe finite magnitude are rejected. Exact large integers use decimal strings.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Retain the field-width, bit-index and byte-order conventions when combining operations. Slicing, escaping, permutation and alignment are separate transforms; none supplies a complete framing or cryptographic protocol.
References
Similar or alternative tools
- Bitfield Overlap Mask
Intersect exact nonnegative integer bit masks and retain the overlapping mask as decimal text.
- Bitfield Gap Inventory
Inventory unoccupied bit positions and positive-width field overlaps in a bounded register; half-open spans.