Bitwise Hex Calculator

Enter hexadecimal values and calculate AND, OR, XOR, and NOT while seeing the matching binary pattern.

Number A
Hex
Dec46 Bin00101110
Number B Hex
Dec74 Bin01001010

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 bit 0 Diff bit 0 Included zero 0 Leading zero

Interactive Truth Table Matrix

Click a row to load values into A and B, or inspect how each gate behaves.

Input AInput BANDORXORNOT A
000001
010111
100110
111100
Click a truth table row to test those values.

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.

Hex Input

Use compact hexadecimal values such as 2E, 4A, FF, or 0x80.

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.

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.

InputOperationResultUse
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.

Hex-Only Input

Enter values such as 2E, FF00, or DEADBEEF without converting them first.

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.

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.

Memory Dumps

Check masks against bytes from a debugger or hex editor.

Hardware Addresses

Test the multicast and locally administered bits of a MAC address.

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.

HexBinaryDecimalHexBinaryDecimal
000000810008
100011910019
200102A101010
300113B101111
401004C110012
501015D110113
601106E111014
701117F111115

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.

0x2E & 0x4A  →  (2 & 4)(E & A)  →  (0)(A)  →  0x0A
0x2E | 0x4A  →  (2 | 4)(E | A)  →  (6)(E)  →  0x6E
0x2E ^ 0x4A  →  (2 ^ 4)(E ^ A)  →  (6)(4)  →  0x64

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:

MaskBinary patternTypical use
0x0F0000 1111low nibble of a byte
0xF01111 0000high nibble of a byte
0xFF1111 1111low byte of a larger integer
0xFF001111 1111 0000 0000high byte of a 16-bit value
0x801000 0000sign bit of an 8-bit value
0x7FFFFFFFall bits except the 32-bit sign bitlargest signed 32-bit integer
0xFFFFFFFF32 onesunsigned 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 = 30
const green = (color >> 8)  & 0xFF;  // 0x90 = 144
const 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.

Hex Literals and Formatting in Code

print(hex(0x2E & 0x4A))        # '0xa'
print(f"{0x2E ^ 0x4A:#04x}")   # '0x64'
print(int("2E", 16))           # 46
console.log((0x2E | 0x4A).toString(16).toUpperCase());  // "6E"
console.log(parseInt("4A", 16));                         // 74
#include <stdio.h>
printf("0x%02X\n", 0x2E & 0x4A);   /* 0x0A */

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.

Frequently Asked Questions

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.