Numbers, Bitwise & Units

bitwise calculatorFollow every flag

Choose a width, edit the operand bits, and compare the resulting mask.

bitwise calculator

Input

Bit 0 is the least significant bit. Checkboxes directly edit the operand.

Results

Decimal result
8
Unsigned decimal
8
Signed decimal
8
Binary
00001000
Hexadecimal
0x08
Octal
0o10
70
60
50
40
31
20
10
00

Set bit positions (1): 3

Your input is processed in this browser and is not sent to a server.

Options

One integer per operand, up to 256 characters. Select a matching base for 0b/0o/0x; no fractions or separators.

Signed mode accepts negative integers and interprets the highest bit as the sign. Arithmetic right shift extends it.

Calculation ready.

A bitwise calculator helps when a permission value or register contains several flags at once. Put the observed value in A and the mask in B to see exactly which positions survive an AND operation.

The bitmask calculator keeps bit positions beside the number. Unlike a quick JavaScript Number expression, its integer calculation preserves every bit through the full unsigned 64-bit range.

Why use this bitwise calculator?

See the intersection

The bitwise calculator shows the common set bits, their zero-based positions and their count. For the initial 12 AND 10 example, only bit 3 remains, giving 8. Toggle that position in either input and watch the intersection change.

Two rows of eight cells feed a third row that retains only their shared active cell.

Compare two kinds of right shift

With signed 8-bit A=240 and a shift of 2, logical right shift gives 60 while arithmetic right shift gives −4. The bit pattern exposes the difference between adding zeros and extending the sign.

An eight-cell pattern branches into a right shift with empty leading cells and a right shift with filled leading cells.

Read the input before changing its meaning

01

Interpret the same text deliberately

The default is decimal, 8-bit unsigned, A=12, B=10 and AND. Changing the input base reinterprets the existing text; it does not convert it. Prefixes must match the selected base.

02

Edit flags and choose the operation

Checkboxes edit A or B directly. Bit 0 is the least significant position; rows run from higher to lower indices. NOT and shifts hide B, and the shift count is a separate decimal field.

03

Review changes before exporting

Automatic calculation waits 350 ms. Turn it off for Calculate or Ctrl/Cmd + Enter. Example, Clear and Swap show a replacement preview; Undo restores the previous inputs, settings and result.

From individual flags to complete words

Mask, set and toggle

Use bitwise AND to isolate a mask, OR to enable selected flags, and the XOR calculator to toggle them. With A=5 and B=3, the respective results are 1, 7 and 6. XOR is a flag operation here, not an encryption scheme.

Keep all 64 positions

Unsigned 64-bit 18446744073709551615 remains exact. Decimal includes both signed and unsigned readings; binary is padded to the selected width and hexadecimal to its matching digit count. Octal is also available in the result.

Inspect shifts without hidden wrapping

The bit shift calculator separates left shift, zero-fill right shift and sign-extending right shift. Its shift count never wraps modulo 32. Set-bit indices and the count are derived from the fixed-width output, including negative signed results.

Width, input and shift rules

Reject oversized input
Positive raw patterns may be 0 through 2^w−1, even in signed mode. Negative inputs require signed mode and must be at least −2^(w−1). Values outside those limits fail instead of silently wrapping. Increase the width to accept a larger value.
Truncate operation results
NOT inverts exactly w bits; left shift discards bits that leave the word. Shift counts must be decimal integers from 0 through w. At w, left and logical right shift produce zero; arithmetic right shift produces all zeros or all ones.
Accept integer text only
Inputs allow ASCII digits, an optional sign and a matching 0b, 0o or 0x prefix. Only outside spaces and tabs are trimmed. Internal separators, line breaks, fractions and decimal scientific notation are rejected. Each operand is limited to 256 characters.
Separate sign from the stored pattern
Signed mode changes decimal interpretation, not the binary or hex word. Arithmetic right shift is available only while signed mode is on; turning it off selects logical right shift. Widening textual −1 extends its sign, while widening textual 255 keeps the positive value.
Keep the scope to integer masks
There is no rotation, NAND/NOR/XNOR, expression evaluator, floating-point mode or unlimited width. Flags use numeric positions; importing named schemas, files or URLs and saving a persistent history are not supported.

Bitwise calculator questions

Does operand B matter for NOT?

No. NOT uses A alone and inverts each bit within the selected width. B is hidden and is not validated or included in the exported report for this operation. A bad value left in B cannot invalidate a NOT result.

What is the difference between logical and arithmetic right shift?

Logical shift fills the high positions with zeros. Arithmetic shift repeats the sign bit and requires signed mode here. For the 8-bit pattern 11110000, shifting right by two gives 00111100 or 11111100 respectively.

What input formats are accepted?

Select binary, octal, decimal or hexadecimal for both operands. Matching prefixes are optional, so select hex before entering 0xFF. Negative mathematical values require signed mode; fractional values and expressions are not evaluated.

Why is there a width selector?

Width determines the size of the word, the sign bit and which bits NOT or left shift can affect. This bitwise calculator offers 8, 16, 32 and 64 bits. It rejects an input that cannot fit instead of choosing a width for you.

What is a bitwise AND operation?

AND sets an output bit only when both input bits at that position are 1. Thus 12 (00001100) AND 10 (00001010) gives 8 (00001000). Set B to a mask to find which of its flags are present in A.

Something looks wrong?

Open the bitwise calculator

Use the bitwise calculator to check one mask, then change the width or a single flag and compare the new result. Export only after the current calculation is ready.