Overview
Hexadecimal (hex) is a base-16 number system that uses 16 distinct symbols (0-9 and A-F) to represent values. It's commonly used in computing and digital systems to represent binary data in a more human-readable format.
Technical Details
Character Set
- Numbers (0-9)
- Letters (A-F)
- Case-insensitive
Key Features
- Compact representation
- Easy to convert to binary
- Widely used in computing
- Human-readable
Common Uses
- Memory addresses
- Color codes
- MAC addresses
- Binary data representation
Examples
Text to Hex
Original: Hello World! Hex: 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 Original: 😊 Hex: F0 9F 98 8A
Color Codes
Red: #FF0000 Green: #00FF00 Blue: #0000FF
Implementation
JavaScript Example
// Text to Hex
function textToHex(text) {
return Array.from(text)
.map(char => char.charCodeAt(0).toString(16).padStart(2, '0'))
.join(' ');
}
// Hex to Text
function hexToText(hex) {
return hex.split(' ')
.map(hex => String.fromCharCode(parseInt(hex, 16)))
.join('');
}
// Example usage
const text = "Hello World!";
const hex = textToHex(text);
console.log(hex); // "48 65 6C 6C 6F 20 57 6F 72 6C 64 21"
const decoded = hexToText(hex);
console.log(decoded); // "Hello World!"