Module
Hex to Binary for Bitmasks & Memory Addresses
Read Bitmasks, Flags & Memory Addresses in Hex and Binary
Module
Read Bitmasks, Flags & Memory Addresses in Hex and Binary
A single hex digit is exactly 4 bits — no rounding, no partial digit — so hex is really just a compact way of writing binary down without a wall of 1s and 0s. That's why permission flags, network masks, and memory addresses are almost always shown in hex: the value you're reading is really a pattern of individual bits, and hex is the shorthand, not a different kind of number. Converting between the two on the main base converter is how you get from the shorthand back to the bits you actually need to read.
Unix's open() file flags are a real example: O_WRONLY is octal 1, O_CREAT is octal 100 (decimal 64), and O_TRUNC is octal 1000 (decimal 512) — each one a single bit, chosen so they never overlap. Combine all three (write-only, create if missing, truncate if it exists) and you get octal 1101, decimal 577, hex 0x241, binary 1001000001. Enter 241 in the hex field and the binary field shows exactly which bits are set — the 1s at positions 0, 6, and 9 correspond to those three flags, and everything in between is 0 because nothing else was combined in. That's the whole technique: convert the combined value to binary, then match each 1-bit back to the flag it represents.
A subnet mask like 255.255.255.0 is four separate 8-bit values, but stacked together as one 32-bit number it's 0xFFFFFF00 — binary 11111111 11111111 11111111 00000000. Count the leading 1-bits and you get the CIDR prefix length people write as /24: 24 consecutive 1s marking the network portion of an address, followed by 8 zero-bits for the host portion. Typing FFFFFF00 into the hex field and reading off the binary is a faster way to confirm a CIDR prefix than counting through four decimal octets by hand.
Hex's clean 4-bit-per-digit grouping also makes alignment visible at a glance. The address 0x1000 is 4096 in decimal — binary 1 followed by twelve 0s — and those three trailing zero hex digits are exactly why it's a common page-aligned address: a value is aligned to 4096 bytes precisely when its lowest three hex digits are all zero. Debuggers and allocators print addresses in hex specifically so alignment like this reads directly off the digits, without anyone having to convert to binary and count zero-bits by hand first.
This converter shows the arithmetic value of a number, not how it's laid out in memory. A 4-byte hex value like 0x12345678 is stored, on a little-endian system (x86 and ARM in their default mode), as the bytes 78 56 34 12 — reversed at the byte level, though the bits inside each byte stay in order. If you're reading a hex dump or a packet capture and need to know which byte came first on the wire or in RAM, that's a fact about the format you're reading, not something the arithmetic conversion here will tell you. It also doesn't perform bitwise operations — no live AND, OR, or XOR between two values — it only converts a single number between bases; combining flags like the open() example above is still addition (or OR, equivalently, since the bits don't overlap) you do yourself before typing the result in.