Decimal โ Hexadecimal Converter
Convert between decimal and hexadecimal numbers instantly
๐ Decimal โ Hexadecimal Conversion Details
Decimal to Hex Formula
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
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:
- Decimal โ Hexadecimal: Divide decimal by 16 repeatedly, convert remainders to hex digits
- Hexadecimal โ Decimal: Multiply each hex digit by appropriate power of 16
- Real-time: Updates happen as you type in either field
- Validation: Hex input accepts only 0-9 and A-F characters
// 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:
Red: 255,0,0
Green: 0,255,0
Blue: 0,0,255
Yellow: 255,255,0
White: 255,255,255
Black: 0,0,0
โ Frequently Asked Questions
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).
A: Hexadecimal is convenient because one hex digit represents exactly 4 binary bits (nibble), making it easier to read and write binary data.
A: This converter handles numbers up to 65,535 (FFFF in hex) for optimal performance, but can handle larger numbers as well.
A: Multiply each hex digit by 16 raised to its position power (starting from 0 on the right), then sum all results.