Hex Arithmetic Calculator
Add, subtract, multiply, or divide hexadecimal numbers. Column workings and decimal equivalents shown.
Number Base Converter
Convert between hex, decimal, binary, and octal. Edit any field to update all others instantly.
Hex Colour Converter
Enter a hex colour code or RGB values to convert and preview. Supports 3 and 6 digit codes.
ASCII to Hex Encoder
Convert text to hex bytes or hex bytes back to readable text. One hex pair = one ASCII character.
Hex Reference Table
Full conversion table: hex, decimal, binary, and octal for values 0 through FF (0 through 255).
| Hex | Dec | Binary | Oct |
|---|
The Hexadecimal System
Hexadecimal uses base 16. Its sixteen digits are 0 through 9 for values zero to nine, then A through F for values ten through fifteen. Each position represents a power of 16, exactly as each position in decimal represents a power of 10.
Converting Decimal to Hex
Divide the decimal number by 16 repeatedly, recording the remainder at each step. Remainders of 10 through 15 are written as A through F. Read the remainders from last to first.
| Hex | Decimal | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0000 | 0 |
| 9 | 9 | 1001 | 11 |
| A | 10 | 1010 | 12 |
| F | 15 | 1111 | 17 |
| 10 | 16 | 0001 0000 | 20 |
| FF | 255 | 1111 1111 | 377 |
| 100 | 256 | 1 0000 0000 | 400 |
Hex Arithmetic
Addition
Add column by column from right to left. When a column sum exceeds F (15), subtract 16 and carry 1 to the next column. The letter digits A through F simply represent the decimal values 10 through 15.
Subtraction
Subtract column by column. Borrow from the next column when the top digit is smaller than the bottom digit. Each borrow adds 16 to the current column (not 10 as in decimal).
Multiplication
Multiply each digit pair, convert any result above 15 by taking the quotient as a carry and the remainder as the current digit. Long multiplication with positional shifting works the same as in decimal.
Hex Colour Codes
HTML and CSS colour codes use the format #RRGGBB, where RR, GG, and BB are two-digit hex values for the red, green, and blue channels. Each channel ranges from 00 (0) to FF (255), giving 256 possible intensities per channel and 256³ = 16,777,216 total colours.
| Colour Name | Hex Code | Red (hex) | Green (hex) | Blue (hex) | RGB Decimal |
|---|---|---|---|---|---|
| White | #FFFFFF | FF (255) | FF (255) | FF (255) | rgb(255,255,255) |
| Black | #000000 | 00 (0) | 00 (0) | 00 (0) | rgb(0,0,0) |
| Red | #FF0000 | FF (255) | 00 (0) | 00 (0) | rgb(255,0,0) |
| Lime | #00FF00 | 00 (0) | FF (255) | 00 (0) | rgb(0,255,0) |
| Blue | #0000FF | 00 (0) | 00 (0) | FF (255) | rgb(0,0,255) |
| Orange-Red | #FF5733 | FF (255) | 57 (87) | 33 (51) | rgb(255,87,51) |
| Grey (50%) | #808080 | 80 (128) | 80 (128) | 80 (128) | rgb(128,128,128) |
Short Hex Codes
CSS also accepts 3-digit hex codes like #F53, where each digit is doubled to form the full code: #F53 expands to #FF5533. This works when each channel has both digits the same (e.g. #AA = #AAAA is not valid; only when both digits in each pair are identical can the pair be condensed to one digit).
Hex in Computing
Hexadecimal is the standard notation for raw computer data because the relationship between hex and binary is exact and compact. One hex digit always represents exactly 4 binary bits (a nibble). Two hex digits always represent exactly 8 bits (one byte). This makes it easy for humans to read and write binary data without the visual noise of long strings of 0s and 1s.
Memory Addresses
Processor and memory addresses are written in hex. A 32-bit address like 0x7FFE1234 is far more readable than 32 binary digits. Modern 64-bit systems have addresses up to 16 hex digits: 0x00007FFF7ABCDEF0. The 0x prefix indicates a hex literal in most programming languages.
ASCII and Unicode
Text encoding uses hex to represent character codes. ASCII 'A' is hex 41 (65 decimal). A space is hex 20 (32 decimal). Unicode code points are written as U+XXXX where XXXX is hex: U+00E9 is é (Latin small letter e with acute), U+1F600 is 😀 (grinning face emoji).
Network Protocols
MAC addresses use 6 bytes in hex separated by colons: 00:1A:2B:3C:4D:5E. IPv6 addresses use 8 groups of 4 hex digits: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Network packet dumps show raw bytes in hex, making hex literacy essential for network analysis.
Machine Code and Assembly
CPU instructions and their operands are written in hex in debuggers, disassemblers, and binary editors. The x86 instruction MOV EAX, 1 compiles to the bytes B8 01 00 00 00. A hex editor shows the raw bytes of any file, which is how binary file formats are analysed and reverse-engineered.