Understanding Number Bases
All digital computers work in binary — sequences of 0s and 1s representing electrical signals that are either off or on. Hexadecimal (base 16) is particularly prevalent in computing because each hex digit represents exactly 4 binary digits (bits), making it a compact and convenient representation of binary data. Understanding number base conversion is fundamental to programming, digital electronics, networking, and cybersecurity.
How to Convert Hex to Decimal
To convert a hexadecimal number to decimal, multiply each digit by 16 raised to the power of its position (counting from right, starting at 0), then sum the results.
Example: Convert hex 1A3 to decimalPosition: 2 1 0
Hex digit: 1 A 3
Decimal: 1 10 3= (1 × 16²) + (10 × 16¹) + (3 × 16⁰)
= 256 + 160 + 3 = 419
Hexadecimal in Everyday Computing
Hex notation appears constantly in computing. Web and CSS colour codes like #FF5733 are hex values representing red, green, and blue channel intensities from 00 (0) to FF (255). Memory addresses in debuggers are shown in hex. Unix file permissions use octal. IPv6 addresses and MAC addresses use hexadecimal. When you see a colour like #38bdf8 in CSS, that is R=38 (56), G=BD (189), B=F8 (248) — a sky blue.
Common Hex Values Every Developer Should Know
- 0x00 = 0 — null byte, string terminator in C
- 0x0A = 10 — newline (LF) in Unix/Linux
- 0x20 = 32 — space character in ASCII
- 0x41 = 65 — uppercase 'A' in ASCII
- 0x61 = 97 — lowercase 'a' in ASCII
- 0xFF = 255 — maximum value of one byte
- 0xFFFF = 65,535 — maximum unsigned 16-bit integer
- 0x7FFFFFFF = 2,147,483,647 — maximum positive signed 32-bit integer
- 0xDEADBEEF — famous debugging magic number for uninitialised memory
Frequently Asked Questions
What does hex mean and why is it used in computing?
Hex is short for hexadecimal, base 16. It uses digits 0–9 and letters A–F. Each hex digit maps to exactly 4 binary bits, making it a compact human-readable shorthand for binary data. A byte (8 bits) is always exactly two hex digits.
How do I convert decimal to hex manually?
Divide the decimal number by 16 repeatedly, recording the remainder each time. The remainders read from bottom to top give the hex digits. For example: 255 ÷ 16 = 15 remainder 15 (F), then 15 ÷ 16 = 0 remainder 15 (F), giving 0xFF.
What is the difference between signed and unsigned integers?
An unsigned integer only represents zero and positive values. An 8-bit unsigned integer ranges from 0 to 255. A signed integer can represent negative values using two's complement. An 8-bit signed integer ranges from -128 to 127.
What does 0x mean in front of hex numbers?
The 0x prefix is a C-language convention indicating the following digits are hexadecimal. So 0xFF means the hex value FF (255 in decimal). Other common prefixes include # (used in CSS colours).
How are hex colours used in CSS?
CSS hex colours use #RRGGBB where RR, GG, and BB are two-digit hex values for the red, green, and blue channels. Each ranges from 00 (0) to FF (255). A 3-digit shorthand #RGB is also valid where each digit is doubled: #F57 equals #FF5577.
What is octal and where is it used?
Octal is base 8, using digits 0–7. Each octal digit represents 3 binary bits. Most commonly used in Unix/Linux file permissions: chmod 755 means owner has rwx (7=111), group has r-x (5=101), others have r-x (5=101).
What is the largest number that fits in 32 bits?
The largest unsigned 32-bit integer is 4,294,967,295 (0xFFFFFFFF). The largest positive signed 32-bit integer is 2,147,483,647 (0x7FFFFFFF).
What is ASCII and how does it relate to hex?
ASCII maps numbers 0–127 to characters including letters, digits, and control codes. ASCII values are often expressed in hex: 0x41 is 'A', 0x61 is 'a', 0x20 is a space.
What does DEADBEEF mean in programming?
0xDEADBEEF is a famous hex magic number used by debuggers to mark uninitialised or freed memory. If a program reads this value from a pointer, it indicates a use-after-free or uninitialised memory bug.
How do negative numbers work in binary?
Most computers use two's complement for negative numbers. To convert positive to negative: invert all bits, then add 1. In 8-bit: +5 = 00000101 → invert → 11111010 → add 1 → 11111011 = -5.
Is my data private when I use this tool?
Yes. All conversions run entirely in your browser using JavaScript. Nothing you enter is sent to any server or stored anywhere.