Glossary

Hexadecimal

hexbase 16

Hexadecimal is a base-16 notation that uses the symbols 0–9 and A–F to represent numbers and bytes compactly.

Definition

Hexadecimal, or hex, is a positional numeral system with base 16. Its digits are 0 through 9 followed by A through F, where A represents decimal 10 and F represents decimal 15.

Hex is widely used to display binary data because one hexadecimal digit corresponds exactly to 4 bits and two digits can represent one byte from 00 to FF.

How it works

As in decimal notation, each position has a place value, but powers of 16 replace powers of 10. Thus 2F means 2 × 16 + 15, which is decimal 47. Uppercase and lowercase letters normally have the same value.

Programs often mark a hexadecimal number with a 0x prefix, while byte dumps may insert spaces or colons. Such prefixes and separators are formatting conventions rather than hexadecimal digits.

Practical example

The UTF-8 text Hi consists of the bytes 48 69 in hex. Converting those byte pairs back and interpreting them as UTF-8 recovers Hi. The same bytes can instead be represented as Base64 SGk=.

A hex byte string uses two text characters per byte, so it is easy to inspect but about twice the size of the raw data.

Interpretation and pitfalls

A hex string does not identify what its bytes mean. They may represent text, a number, a file, a hash, or ciphertext. Decoding bytes as text also requires the correct character encoding. For byte-oriented decoding, an odd number of hex digits is incomplete unless a leading zero is implied by an agreed convention.

Hexadecimal notation is reversible and is not encryption; it provides no confidentiality.

Frequently asked questions

No. Hexadecimal only changes the written representation of numbers or bytes. Anyone can convert a valid hex value back without a key.

A byte is normally written as two hex digits. An odd-length byte string leaves one nibble unpaired, although ordinary hexadecimal integers themselves may have any number of digits.

No. A–F and a–f normally have identical numeric values, though a particular output format may require one style.

See also
Related tools
Related terms