Enter hexadecimal values and calculate AND, OR, XOR, and NOT while seeing the matching binary pattern.
Number A
Hex
Dec46Bin00101110Hex0x2E
Invalid input.
Value exceeds selected bit width.
Number BHex
Dec74Bin01001010Hex0x4A
Invalid input.
Value exceeds selected bit width.
Results Summary
AND (&)
Dec0
Hex0x00
Bin00000000
OR (|)
Dec0
Hex0x00
Bin00000000
XOR (^)
Dec0
Hex0x00
Bin00000000
NOT (~A)
Dec0
Hex0x00
Bin00000000
Bit-by-Bit Visualization
1 Active bit0 Diff bit0 Included zero0 Leading zero
Interactive Truth Table Matrix
Click a row to load values into A and B, or inspect how each gate behaves.
Input A
Input B
AND
OR
XOR
NOT A
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
1
0
1
1
1
1
0
0
Click a truth table row to test those values.
Copied.
How the Bitwise Hex Calculator Works
A bitwise hex calculator converts hexadecimal values to binary, applies the selected bitwise operation, and returns the result in hex, decimal, and binary formats.
0x
Hex Input
Use compact hexadecimal values such as 2E, 4A, FF, or 0x80.
bin
Binary Expansion
Each hex digit expands into four bits for exact bitwise comparison.
&|^
Operator Support
Run AND, OR, XOR, and NOT checks from the same visual interface.
8
Byte Friendly
Hex output is ideal for bytes, registers, masks, and packed fields.
Hex Bitwise Calculation Steps
Use these steps to calculate bitwise operations from hexadecimal input.
Convert Hex to Binary
Map each hex digit to four binary bits.
Align both binary values.
Keep the selected bit width.
Apply the Operator
Use AND, OR, XOR, or NOT rules.
Compare each binary column.
Keep included zeros in the result.
Return Hex Output
Group binary output into nibbles.
Convert each nibble back to hex.
Check decimal output when needed.
Hex Bitwise Examples
Hex examples are compact ways to inspect byte and word masks.
Input
Operation
Result
Use
0x2E & 0x4A
AND
0x0A
Shared mask bits
0x2E | 0x4A
OR
0x6E
Combined flags
0x2E ^ 0x4A
XOR
0x64
Different bits
~0x2E
8-bit NOT
0xD1
Byte complement
Why Use This Bitwise Hex Calculator?
Use this hex calculator when source values are shown as register bytes, color channels, flags, or memory dumps.
0x
Hex-Only Input
Enter values such as 2E, FF00, or DEADBEEF without converting them first.
4b
Nibble Expansion
Each hex digit is shown as its 4-bit binary group so you can follow the operation.
&|^
Every Operator
Run AND, OR, XOR, and NOT on the same hex pair.
00
Zero-Padded Output
Results are padded to the chosen width, such as 0x0A for a byte.
Practical Uses for Hex Bitwise Math
Hex bitwise calculations are common in firmware, graphics, networking, and debugging.
#
Colour Channels
Extract red, green, and blue from #1E90FF with shifts and & 0xFF.
mem
Memory Dumps
Check masks against bytes from a debugger or hex editor.
MAC
Hardware Addresses
Test the multicast and locally administered bits of a MAC address.
reg
Firmware Registers
Apply datasheet masks such as 0x0F or 0xF0 to register values.
Why Programmers Use Hexadecimal
Hexadecimal (base 16) uses the digits 0–9 and the letters A–F for the values 10 to 15. Its big advantage is that one hex digit is exactly four bits, so converting between hex and binary is a simple lookup with no arithmetic.
Hex
Binary
Decimal
Hex
Binary
Decimal
0
0000
0
8
1000
8
1
0001
1
9
1001
9
2
0010
2
A
1010
10
3
0011
3
B
1011
11
4
0100
4
C
1100
12
5
0101
5
D
1101
13
6
0110
6
E
1110
14
7
0111
7
F
1111
15
A byte is always two hex digits (00 to FF), and a 32-bit value is always eight. Memory dumps, colour codes, MAC addresses, and register maps all use hex for that reason.
Hex Bitwise Operations Nibble by Nibble
Because each hex digit is an independent group of 4 bits, you can apply a bitwise operator one digit at a time. There is no carrying between digits.
Take E & A. Expand both digits: 1110 & 1010 = 1010, which is A. With a little practice, the common digit pairs become memorised facts, such as F & x = x, 0 | x = x, and F ^ x being the complement of x.
Masks You'll See Everywhere
Certain hex values appear in almost every codebase, so it pays to recognise them:
Mask
Binary pattern
Typical use
0x0F
0000 1111
low nibble of a byte
0xF0
1111 0000
high nibble of a byte
0xFF
1111 1111
low byte of a larger integer
0xFF00
1111 1111 0000 0000
high byte of a 16-bit value
0x80
1000 0000
sign bit of an 8-bit value
0x7FFFFFFF
all bits except the 32-bit sign bit
largest signed 32-bit integer
0xFFFFFFFF
32 ones
unsigned 32-bit wrap-around
Reading value & 0xFF00 as “keep the second byte” is much faster than working out what value & 65280 means.
Hex Colours: A Real-World Example
Web colours such as #1E90FF are three bytes packed into one 24-bit number: red 1E, green 90, blue FF. Extracting a channel is a shift followed by an AND:
const color = 0x1E90FF;const red = (color >> 16) & 0xFF; // 0x1E = 30const green = (color >> 8) & 0xFF; // 0x90 = 144const blue = color & 0xFF; // 0xFF = 255
To darken the colour by clearing the low bits of each channel, AND with 0xF0F0F0: 0x1E90FF & 0xF0F0F0 = 0x1090F0. You can verify each step with this hex calculator.
Note that hex output is often shown without leading zeros (0xa). Pad it to the field width (0x0A, 0x000A) when the width matters, as this calculator does when you choose 8, 16, 32, or 64 bits.
Hex, Endianness, and Byte Order
A 32-bit value such as 0x12345678 is stored as four bytes. On a little-endian machine (x86, most ARM systems), memory holds them as 78 56 34 12. On a big-endian system, or in network byte order, they appear as 12 34 56 78. Bitwise operators always work on the value, not on its memory layout, so 0x12345678 & 0xFF is 0x78 on every platform. Byte order only matters when you read raw bytes from a file, a packet, or a memory dump.
Common Hex Mistakes
Mixing up 0x10 and 10.0x10 is sixteen.
Dropping leading zeros in a fixed-width field.0x0A and 0xA are equal, but a byte-oriented protocol expects two digits.
Applying NOT without a width.~0x0F is 0xF0 only at 8 bits.
Confusing hex digits with letters in strings. Validate input to 0–9 and A–F (any case) before parsing.
Find answers to common questions about bitwise operations and this online tool.
Why is hex used for bitwise work?
Each hex digit is exactly 4 bits, so you can convert between hex and binary digit by digit. That makes masks such as 0xF0 or 0xFF00 easy to read.
How do I do a bitwise AND on hex numbers by hand?
Apply the operator one hex digit at a time, because no carries cross digit boundaries. 0x2E & 0x4A = (2 & 4)(E & A) = 0x0A.
What does 0xFF mean in a mask?
0xFF is eight 1 bits. value & 0xFF keeps the lowest byte and clears everything above it.
Is hex input case sensitive?
No. 2e, 2E, 0x2e, and 0x2E all represent decimal 46.
Does endianness change bitwise results?
No. Bitwise operators work on the numeric value, so 0x12345678 & 0xFF is 0x78 on every platform. Byte order only matters when reading raw bytes from memory, files, or networks.
How do I print hex with leading zeros?
Use a width in the format string, such as printf("%02X") in C, f"{x:02X}" in Python, or x.toString(16).padStart(2, "0") in JavaScript.