Decimal โ†” Hexadecimal Converter

Convert between decimal and hexadecimal numbers instantly

Enter decimal (base-10) number (0-65535)
Enter hexadecimal (base-16) number
Conversion Result
255โ‚โ‚€ = FFโ‚โ‚†
Binary: 11111111โ‚‚ โ€ข Bits: 8

๐Ÿ“š Decimal โ†” Hexadecimal Conversion Details

Decimal to Hex Formula

// Divide by 16, track remainders
255 รท 16 = 15 remainder 15
15 รท 16 = 0 remainder 15
Result: FF (15=F, 15=F)

Repeatedly divide by 16 and use remainders (0-15 โ†’ 0-9,A-F)

Hex to Decimal Formula

// Multiply digits by 16^n
FF = Fร—16ยน + Fร—16โฐ
= 15ร—16 + 15ร—1
= 240 + 15 = 255

Multiply each digit by 16^n where n is digit position from right

Bidirectional Conversion

This converter works both ways simultaneously:

  • Type decimal โ†’ hex updates automatically
  • Type hex โ†’ decimal updates automatically
  • Real-time conversion as you type

Common Uses

  • Computer programming
  • Color codes (RGB/HEX)
  • Memory addresses
  • Digital electronics

๐Ÿ”ข How This Converter Works

This is a bidirectional converter for number systems:

  1. Decimal โ†’ Hexadecimal: Divide decimal by 16 repeatedly, convert remainders to hex digits
  2. Hexadecimal โ†’ Decimal: Multiply each hex digit by appropriate power of 16
  3. Real-time: Updates happen as you type in either field
  4. Validation: Hex input accepts only 0-9 and A-F characters
// Conversion Algorithms

// Decimal to Hexadecimal
function decimalToHex(decimal) {
  return decimal.toString(16).toUpperCase();
}

// Hexadecimal to Decimal
function hexToDecimal(hex) {
  return parseInt(hex, 16);
}

๐Ÿ“Š Common Conversion Table

Decimal Hexadecimal Binary
0 0 0000
1 1 0001
10 A 1010
15 F 1111
16 10 00010000
255 FF 11111111
256 100 000100000000
4096 1000 0001000000000000

๐ŸŽจ Hexadecimal Color Codes

Hexadecimal is commonly used for color codes in web design:

#FF0000
Red: 255,0,0
#00FF00
Green: 0,255,0
#0000FF
Blue: 0,0,255
#FFFF00
Yellow: 255,255,0
#FFFFFF
White: 255,255,255
#000000
Black: 0,0,0

โ“ Frequently Asked Questions

Q: What is hexadecimal numbering system?

A: Hexadecimal is a base-16 number system using digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15).

Q: Why is hexadecimal used in computing?

A: Hexadecimal is convenient because one hex digit represents exactly 4 binary bits (nibble), making it easier to read and write binary data.

Q: What is the largest decimal number this converter handles?

A: This converter handles numbers up to 65,535 (FFFF in hex) for optimal performance, but can handle larger numbers as well.

Q: How do I convert hex to decimal manually?

A: Multiply each hex digit by 16 raised to its position power (starting from 0 on the right), then sum all results.