Binary Calculator
Convert between binary, decimal, hex, and octal, then run bitwise AND, OR, XOR, NOT and shifts at a chosen 8/16/32/64-bit width — with signed/unsigned and two’s-complement views. BigInt-backed so 64-bit math stays exact.
Base converter
Bitwise operation
What this calculator does
This is a binary calculator built for embedded and security engineers who spend their days staring at registers, status words, and bit-packed flags. The left panel is a live base converter: type a value once and read it back in binary, decimal, hexadecimal, and octal at the same time. The right panel runs the bitwise operations you reach for when masking flags or assembling protocol fields — AND, OR, XOR, NOT, and the three shifts (left, logical right, arithmetic right). Both panels share the same notion of operand width and signedness, so the bit pattern you convert is the bit pattern you operate on.
Everything is computed with JavaScript BigInt and then masked to the selected width. That matters more than it sounds: the native JavaScript bitwise operators silently coerce their inputs to signed 32-bit integers, so a 64-bit mask, a 40-bit APDU field, or any value past 2147483647 comes out wrong. Using BigInt and an explicit width mask keeps 8, 16, 32, and 64-bit results exact and lets the signed view show genuine two’s-complement values.
When to use it
Reach for it whenever a value crosses a representation boundary. Decoding a smart-card status word and need to see 0x9000 as bits? Building an ISO 7816 class byte or an EMV tag bitmap one flag at a time? Checking that a left shift wraps the way the silicon will at 8 bits? Confirming that 0xFF is −1 when a field is signed? Each of those is a few keystrokes here. It also pairs naturally with byte-order work: convert a value, then take the hex into the endian converter to swap byte order, or into hex bytes to view it as a byte sequence.
Input and output
In the base converter, choose which base your typed value is in and the tool parses it accordingly; you can also paste with a 0x, 0b, or 0o prefix and it will infer the base. The output shows all four bases plus a nibble-grouped binary view (four bits per group) so long patterns stay readable. In the bitwise panel, operands A and B are read in the selected operand base; for NOT only operand A is used, and for shifts operand B is the shift amount. Results are masked to the active width and reported in binary, hex, decimal (both unsigned and signed two’s-complement), and octal. If a value does not fit the width, the high bits are dropped and the tool flags the truncation rather than hiding it.
Common mistakes
- Trusting native JS bit-ops past 32 bits.
(0xFFFFFFFF & 0xFFFFFFFF)evaluates to-1in plain JavaScript. This tool uses BigInt to avoid that trap entirely. - Confusing logical and arithmetic right shift. Shifting a negative signed value right with the logical shift zero-fills the sign bit and changes its meaning; pick the arithmetic shift to preserve sign.
- Forgetting the width when reading two’s complement. The pattern
0x80is −128 at 8 bits but a positive 128 at 16 bits. Set the width to match the register. - Entering a value wider than the field. A 9-bit number in an 8-bit width is truncated; watch for the truncation badge.
- Mixing operand bases. A and B are read in the single selected operand base — switch the base selector rather than prefixing only one operand.