Every number base represents the same quantity, just grouping digits differently. Decimal (base 10) is what humans use daily. Binary (base 2) is what digital hardware actually stores and computes with — every bit is either 0 or 1, matching a transistor's on/off state. Hexadecimal (base 16) is a compact shorthand for binary, since each hex digit represents exactly 4 bits (a "nibble") — making it far easier for humans to read and write long binary values like memory addresses or register contents. Octal (base 8), where each digit represents exactly 3 bits, was more common in older computing systems and is still occasionally seen in Unix file permissions.
| Base | Digits used | Bits per digit | Typical use |
|---|---|---|---|
| Binary | 0-1 | 1 | What hardware actually stores/computes |
| Octal | 0-7 | 3 | Unix file permissions, legacy systems |
| Decimal | 0-9 | — | Everyday human-readable numbers |
| Hexadecimal | 0-9, A-F | 4 | Memory addresses, register values, color codes |
Hexadecimal is not used because programmers enjoy it — it is used because one hex digit maps exactly to four bits. That makes the translation between a human-readable number and the underlying bit pattern purely mechanical, with no arithmetic involved.
Decimal has no such relationship. The byte 0xA5 is instantly readable as 1010 0101, but its decimal form, 165, tells you nothing about which bits are set. Since microcontroller registers are defined bit by bit, hexadecimal is simply the notation that matches the hardware.
| Binary | Hex | Decimal |
|---|---|---|
| 0000 0000 | 0x00 | 0 |
| 0000 1111 | 0x0F | 15 |
| 1010 0101 | 0xA5 | 165 |
| 1111 1111 | 0xFF | 255 |
Setting, clearing and testing individual bits is the daily work of register programming. Writing REG |= 0x08 to set bit 3, or REG &= ~0x08 to clear it, is readable precisely because 0x08 is visibly a single bit in position 3. The decimal equivalent, 8, happens to be just as clear here — but 0x40 versus 64, or 0x2000 versus 8192, is where the advantage becomes obvious.
Signed integers are stored in two’s complement, where the top bit carries negative weight. In an 8-bit signed value, 0xFF is −1 rather than 255, and the range runs from −128 to +127 instead of 0 to 255.
This is the source of a whole family of bugs. Reading a sensor into a signed variable when the data is unsigned turns large readings negative; mixing signed and unsigned types in a comparison can make a loop run the wrong way or never terminate. The usual discipline is to use explicitly sized types — uint8_t, int16_t — so the width and signedness are stated rather than inferred.
Octal survives mainly in Unix file permissions, where three bits per digit maps neatly onto the read, write and execute triplet.
Multiply each bit by its place value (a power of 2, starting from 2^0 on the right) and add the results. For example, 1010 = 1×8 + 0×4 + 1×2 + 0×1 = 10.
Multiply each hex digit by its place value (a power of 16) and add the results, using A=10, B=11, C=12, D=13, E=14, F=15 for the letter digits. For example, FF = 15×16 + 15 = 255.
Hexadecimal is a compact, human-readable shorthand for binary — each hex digit represents exactly 4 bits, so an 8-bit byte becomes just 2 hex digits (e.g. 11111111 = FF) instead of 8 hard-to-read binary digits.
255 in decimal, FF in hex, 11111111 in binary, and 377 in octal — all the same value, representing all 8 bits set to 1.
Multiply each octal digit by its place value (a power of 8) and add the results. For example, 777 (octal) = 7×64 + 7×8 + 7×1 = 511.
It encodes red, green, and blue intensity as three hex byte pairs: FF (255, full red), 57 (87, some green), 22 (34, a little blue) — each pair ranges from 00 (none) to FF (255, maximum) for that color channel.
Because each of the three permission groups (owner, group, others) uses exactly 3 bits (read/write/execute), and octal digits represent exactly 3 bits each — making one octal digit per permission group a natural, compact fit.
2^n - 1 for n bits (unsigned): 1 bit gives 0-1, 4 bits give 0-15, 8 bits give 0-255, 16 bits give 0-65,535, and so on — each added bit doubles the range of representable values.
Not directly — computers most commonly use "two's complement" representation for signed (negative-capable) binary numbers, which is a specific encoding scheme beyond simple base conversion; this calculator handles unsigned (non-negative) base conversion.
Convert each hex digit individually to its 4-bit binary equivalent and concatenate them — since each hex digit maps to exactly 4 bits, there's no need to go through decimal at all (e.g. hex "A5" = binary "1010" + "0101" = "10100101").
Because one hex digit corresponds to exactly four bits, so converting between hex and the underlying bit pattern needs no arithmetic. Decimal has no such alignment with binary.
Translate each hex digit into its four-bit group independently. 0xA5 becomes 1010 0101, since A is 1010 and 5 is 0101.
A value used to isolate or modify specific bits. OR with a mask sets those bits, AND with its complement clears them, and AND with the mask tests them. Masks are written in hex because the bit positions are then visible at a glance.
The standard representation for signed integers, in which the most significant bit carries negative weight. In 8 bits, 0xFF represents −1 and the range is −128 to +127 rather than 0 to 255.
Usually because unsigned data has been stored in a signed variable. Any value with the top bit set is then interpreted as negative. Using explicitly sized types such as uint16_t avoids the ambiguity.
Mainly in Unix file permissions, where each octal digit represents exactly three bits and maps onto the read, write and execute permission triplet.
Scientific Calculator • ADC Resolution Calculator • All Calculators