Bits
bitsAnalyze integers: compute popcount, bit length, trailing zeros, power-of-two checks; perform AND/OR/XOR/shift/rotate operations; convert bases; identify which machine widths hold a value.
Instructions
Programmer-mode integer facts and operations, selected by mode —
replaces the four former standalone tools bit_analysis, bitop,
int_widths and base_repr, retired in 0.12.0 (CHANGELOG.md). Every mode
returns exactly its former tool's own result, plus mode (additive).
mode="analysis" (was bit_analysis) — facts about a single N: popcount,
bit length, trailing zeros, power-of-two check, next power of two. Used
by this mode: n (required), align (optional).
mode="op" (was bitop) — combine two integers a/b with
and/or/xor/nand/nor/xnor/not/shl/shr/sar/rol/ror at a fixed width
(8/16/32/64). Every result shows unsigned,
signed (two's complement), hex, octal and binary. shr is logical
(zero-fill); sar is arithmetic (sign-propagating) — 0x80 shr 1 = 0x40
(+64) but 0x80 sar 1 = 0xC0 (-64); rol/ror rotate bits around the width
instead of shifting them out. A left shift that drops bits says
OVERFLOW and shows the unbounded answer. Used by this mode: a, op
(required), b (required unless op="not"), width (optional).
mode="widths" (was int_widths) — which widths (i8..i64/u8..u64) hold
n, and the wrapped value where they do not; flags anything past 2^53
as unable to round-trip through a JS number or JSON float. Used by this
mode: n (required).
mode="repr" (was base_repr) — hex/oct/bin of n; with width, two's
complement and signed-overflow detection. Used by this mode: n
(required), width (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | No | First operand for mode='op'; required by that mode | |
| b | No | Second operand for mode='op'; required unless op='not' | |
| n | No | The integer to inspect; required by modes 'analysis', 'widths', and 'repr' | |
| op | No | Bit operation for mode='op': and/or/xor/nand/nor/xnor/not/shl/shr/sar/rol/ror | |
| mode | Yes | Which fact/operation to compute: 'analysis', 'op', 'widths', or 'repr' (each has its own required params) | |
| align | No | Alignment boundary for mode='analysis'; reports padding needed to reach it | |
| width | No | Bit width for mode='op' (8/16/32/64, default 64) or mode='repr' (omit to skip width analysis) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||