Hex Calculator

Perform arithmetic operations on hexadecimal numbers. Add, subtract, multiply, or divide hex values with instant results.

Hex Quick Reference

Hex Digits
0-9, A-F
Base-16 number system
A in Decimal
10
A=10, B=11, C=12, D=13, E=14, F=15
FF in Decimal
255
Maximum 2-digit hex value
Common Use
Colors, Memory
Web colors, addresses

Result

Hexadecimal Result
Enter hexadecimal values and select an operation

Key Takeaways

  • Hexadecimal is a base-16 number system using digits 0-9 and letters A-F
  • Each hex digit represents 4 binary bits (a "nibble")
  • Two hex digits can represent values from 0 to 255 (00 to FF)
  • Widely used in computing for colors, memory addresses, and data representation
  • Convert to decimal by multiplying each digit by powers of 16

Understanding Hexadecimal Numbers

Hex Decimal Binary Notes
00000000000Minimum value (null, black in RGB)
0F1500001111Highest single hex digit
101600010000First two-digit hex value
1F3100011111—
3F6300111111—
406401000000—
7F12701111111Signed byte maximum positive value
8012810000000Signed byte becomes negative here
A016010100000—
C019211000000Common subnet mask byte
FF25511111111Maximum byte value (white in RGB)
Note: In hex, each digit represents 4 bits (a "nibble"). Two hex digits represent one byte (8 bits, values 0–255). This is why hex is so common in computing — it maps perfectly to bytes. IPv4 addresses, RGB colors, memory addresses, and machine code are all commonly expressed as hex bytes.
Base Name Digits Used Example (decimal 255) Common Use
Base 2Binary0, 111111111CPU instructions, bit flags, boolean logic
Base 8Octal0–7377Unix file permissions (chmod 755), older systems
Base 10Decimal0–9255Human counting; everyday arithmetic
Base 16Hexadecimal0–9, A–FFFMemory addresses, RGB colors, MAC addresses, HTML colors
Base 64Base64A–Z, a–z, 0–9, +, //w==Encoding binary data in text (email attachments, JWTs)
Note: Prefix conventions: binary = 0b (e.g., 0b11111111); octal = 0o or leading 0 (e.g., 0o377); hexadecimal = 0x (e.g., 0xFF). In HTML/CSS, hex colors use # prefix (e.g., #FF5733). The "0x" prefix is used in C, Python, JavaScript, and most programming languages to denote hexadecimal literals.
Value Hex Common Context Notes
255 (max byte)0xFFRGB color max, subnet masks11111111 in binary — all bits set
256 (byte overflow)0x100First 3-digit hex valuePowers of 2 shift left in hex
4,0960x1000Memory page size (4KB)2^12
65,5350xFFFFMax 16-bit unsigned integerTwo full bytes
65,5360x10000First 5-digit hex2^16
16,777,2150xFFFFFFMax 24-bit value; max RGB color (#FFFFFF = white)Three full bytes
2,147,483,6470x7FFFFFFFMax 32-bit signed integerInt32 maximum
4,294,967,2950xFFFFFFFFMax 32-bit unsigned integerUInt32 maximum
00x00Null, black (#000000), falseAll bits cleared
1270x7FMax signed 8-bit integerInt8 maximum
Note: Powers of 16 are particularly clean in hex: 16^1 = 0x10; 16^2 = 0x100; 16^3 = 0x1000; 16^4 = 0x10000. This is analogous to how powers of 10 work in decimal. Each additional hex digit multiplies the range by 16.

Hexadecimal numbers are a base-16 numeral system that is widely used in computing and digital systems. In hexadecimal, the digits range from 0 to 9, followed by the letters A to F, which represent values 10 to 15 respectively. This allows for concise representation of binary data.

Hex to Decimal: Multiply each digit by 16^position
Example: 3A = (3 x 16^1) + (10 x 16^0) = 48 + 10 = 58

Hexadecimal Digit Values

Hex Decimal Hex Decimal
0 0 8 8
1 1 9 9
2 2 A 10
3 3 B 11
4 4 C 12
5 5 D 13
6 6 E 14
7 7 F 15

Hexadecimal to Decimal Conversion

Converting a hexadecimal number to decimal involves multiplying each digit by the corresponding power of 16 and summing the results. Let's consider an example:

Hex: 3A
Decimal: (3 x 161) + (10 x 160) = 48 + 10 = 58

Decimal to Hexadecimal Conversion

Converting a decimal number to hexadecimal involves dividing the decimal number by 16 repeatedly and noting the remainders. The hexadecimal representation is obtained by writing the remainders in reverse order.

Decimal: 172
172 / 16 = 10 remainder 12 (C)
10 / 16 = 0 remainder 10 (A)
Hex: AC

Arithmetic Operations with Hexadecimal Numbers

Addition in Hexadecimal

Adding hexadecimal numbers follows similar rules to decimal addition. When adding digits, if the sum is greater than or equal to 16, a carry occurs.

Hex: AB + 2F = DA
B(11) + F(15) = 26 = 1A (write A, carry 1)
A(10) + 2 + 1(carry) = 13 = D
Result: DA

Subtraction in Hexadecimal

Subtracting hexadecimal numbers is similar to decimal subtraction. If the value being subtracted is greater than the value being subtracted from, a borrow occurs from the next higher digit.

Multiplication in Hexadecimal

Multiplying hexadecimal numbers involves multiplying each digit and summing the results. If the result is greater than or equal to 16, a carry occurs.

Division in Hexadecimal

Dividing hexadecimal numbers is similar to decimal division. The division process is performed digit by digit, and if the dividend is less than the divisor, a zero is added to the quotient.

Applications of Hexadecimal Numbers

Hexadecimal numbers have various applications in different fields, including math, science, and everyday life:

Computer Science and Programming

Hexadecimal is extensively used in computer science and programming. It provides a concise representation of binary data, making it ideal for low-level programming, memory addressing, bitwise operations, and debugging.

Color Representation

Hexadecimal plays a vital role in representing colors in digital systems. Each color component (red, green, blue) is typically represented by two hex digits, allowing for a wide range of colors to be expressed. For example, #FF5733 represents a shade of orange.

Network Administration

Hexadecimal is used in network administration for tasks such as configuring IP addresses, subnet masks, and port numbers. It provides a compact and efficient representation of these values.

Memory Addressing

Hexadecimal is extensively used in memory addressing. Memory addresses are typically represented in hex format, allowing for efficient allocation and referencing of memory locations.

Cryptography

Hexadecimal plays a significant role in cryptography. Cryptographic algorithms often utilize hex representations for keys, cipher text, and other cryptographic elements. Hex is used to represent binary data in a more manageable and human-readable format.

Web Development

In web development, hexadecimal values are commonly used to represent colors in Cascading Style Sheets (CSS) and other web-related technologies. Hexadecimal color codes provide a wide range of color choices and are widely supported across browsers and platforms.

Conclusion

Hexadecimal numbers are a fundamental part of computing, digital systems, and various applications across multiple fields. Understanding how to convert hexadecimal numbers, perform arithmetic operations, and grasp their practical applications is essential for professionals in computer science, programming, digital electronics, and other related disciplines.

Frequently Asked Questions

How accurate are the results?
The Hex applies a standard formula to your inputs — accuracy depends on how precisely you measure those inputs. For planning and estimation, results are reliable. For high-stakes or professional decisions, cross-check the output with a domain expert or primary source.
Can I use this on mobile?
Yes — the calculator is designed to work on any device. For complex multi-input calculations on small screens, landscape orientation gives more room to see all fields and results simultaneously.
What is hexadecimal and how does it work?
Hexadecimal (hex) is a base-16 number system that uses 16 symbols: the digits 0–9 and the letters A–F. Decimal (base 10) uses 10 symbols (0–9). Binary (base 2) uses 2 symbols (0 and 1). Hex uses 16 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). The letter values: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. How hex counting works: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13… After F (which is 15 in decimal), hex "rolls over" to 10 (which equals 16 in decimal). Just as decimal rolls from 9 to 10, hex rolls from F to 10. Why hex is used in computing: one hex digit represents exactly 4 binary bits (a "nibble"). Two hex digits represent exactly one byte (8 bits). This makes hex a compact, human-readable way to represent binary data — instead of writing 11111111 (8 binary digits), you write FF (2 hex digits). Where you see hex: HTML/CSS colors: #FF5733 (3 bytes: red=FF, green=57, blue=33). Memory addresses: 0x7FFF0000. MAC addresses: 00:1A:2B:3C:4D:5E. IPv6 addresses: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Assembly / machine code: MOV AX, 0x1234. File headers / magic numbers: JPEG files begin with FF D8 FF.
How do you convert hexadecimal to decimal?
Converting hex to decimal uses positional notation, where each hex digit is multiplied by the appropriate power of 16. Method: write out the hex number. Assign positional values (right to left): position 0 = 16^0 = 1; position 1 = 16^1 = 16; position 2 = 16^2 = 256; position 3 = 16^3 = 4,096; etc. Multiply each hex digit by its positional value (using decimal equivalents: A=10, B=11, C=12, D=13, E=14, F=15). Sum all the results. Example 1 — convert 0xFF to decimal: F = 15 at position 1: 15 × 16 = 240. F = 15 at position 0: 15 × 1 = 15. Total = 240 + 15 = 255. Example 2 — convert 0x1A3 to decimal: 1 at position 2: 1 × 256 = 256. A (=10) at position 1: 10 × 16 = 160. 3 at position 0: 3 × 1 = 3. Total = 256 + 160 + 3 = 419. Example 3 — convert 0x2F to decimal: 2 at position 1: 2 × 16 = 32. F (=15) at position 0: 15 × 1 = 15. Total = 32 + 15 = 47. Mental math shortcut: for two-digit hex, the formula is: (first digit × 16) + second digit. So 0xC0 = (12 × 16) + 0 = 192. 0x7F = (7 × 16) + 15 = 112 + 15 = 127. Programming conversion: Python: int("FF", 16) → 255 or int(0xFF) → 255. JavaScript: parseInt("FF", 16) → 255. C: 0xFF is already a hex literal (evaluates to 255).
How do you convert decimal to hexadecimal?
Converting decimal to hex uses repeated division by 16. Method: divide the decimal number by 16. Record the remainder (0–15; remainders 10–15 become A–F). Divide the quotient by 16 again. Repeat until the quotient is 0. Read the remainders from bottom to top (last remainder is the most significant digit). Example 1 — convert 255 to hex: 255 ÷ 16 = 15 remainder 15 (F). 15 ÷ 16 = 0 remainder 15 (F). Read remainders bottom to top: FF. So 255 = 0xFF. Example 2 — convert 419 to hex: 419 ÷ 16 = 26 remainder 3. 26 ÷ 16 = 1 remainder 10 (A). 1 ÷ 16 = 0 remainder 1. Read bottom to top: 1A3. So 419 = 0x1A3. Example 3 — convert 192 to hex: 192 ÷ 16 = 12 remainder 0. 12 ÷ 16 = 0 remainder 12 (C). Read bottom to top: C0. So 192 = 0xC0. Shortcut for powers of 2: if the decimal number is a power of 2, hex conversion is fast: 256 = 0x100; 512 = 0x200; 1,024 = 0x400; 4,096 = 0x1000; 65,536 = 0x10000. Programming conversion: Python: hex(255) → '0xff'. JavaScript: (255).toString(16) → 'ff'. For uppercase: (255).toString(16).toUpperCase() → 'FF'.
How do you add and subtract hexadecimal numbers?
Hex arithmetic follows the same rules as decimal — just with base 16 instead of base 10. Hex addition: add the digits normally. If the sum exceeds 15 (F), write the remainder and carry 1 to the next column. Example — add 0x2B + 0x1F: B (11) + F (15) = 26. 26 = 16 + 10, so write A, carry 1. 2 + 1 + 1 (carry) = 4. Write 4. Result: 0x4A. Verify: 43 + 31 = 74 in decimal; 0x4A = 74. ✓. Example — add 0xFF + 0x01: F + 1 = 16. Write 0, carry 1. F + 0 + 1 (carry) = 16. Write 0, carry 1. Write 1 (from carry). Result: 0x100. Verify: 255 + 1 = 256 = 0x100. ✓. Hex subtraction: subtract digit by digit from right to left. If the top digit is smaller than the bottom digit, borrow 16 from the next column (not 10 as in decimal). Example — 0x4A − 0x1F: A (10) − F (15): can't do it; borrow from next column: 10 + 16 = 26; 26 − 15 = 11 = B. 4 − 1 (borrowed) − 1 = 2. Result: 0x2B. Verify: 74 − 31 = 43; 0x2B = 2×16 + 11 = 43. ✓. Practical tip: for most programming tasks, convert to decimal, do the arithmetic, then convert back — unless you're working at the bit level where hex patterns matter more than the arithmetic.