ArticleslgStudy

science

Hexadecimal

Hexadecimal is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hexadecimal rather than just read about it. In short: Hexadecimal (hex for short) is a positional numeral system for representing a numeric value as base 16. For the most common convention, a digit is represented as "0" to "9" like for decimal and as a letter of the alphabet from "A" to "F" (either upper or lower case) for the digits with decimal value 10 to 15.

Hexadecimal — main illustration
Hexadecimal — illustration

Key takeaways

  • Hexadecimal belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hexadecimal to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hexadecimal from memory before moving on to harder problems.

Reference excerpt

Hexadecimal (hex for short) is a positional numeral system for representing a numeric value as base 16. For the most common convention, a digit is represented as "0" to "9" like for decimal and as a letter of the alphabet from "A" to "F" (either upper or lower case) for the digits with decimal value 10 to 15. As typical computer hardware is binary in nature and that hex is power of 2, the hex representation is often used in computing as a dense representation of binary information. A hex digit represents 4 contiguous bits –known as a nibble. An 8-bit byte is two hex digits, such as 2C. Special notation is often used to indicate that a number is hex. In mathematics, a subscript is typically used to specify the base. For example, the decimal value 491 would be expressed in hex as 1EB16. In computer programming, various notations are used. In C and many related languages, the prefix 0x is used. For example, 0x1EB.

Written representation

Common convention Typically, a hex representation convention allows either lower or upper case letters and treats the letter the same regardless of its case. Often when rendering non-textual data, a value stored in memory is displayed as a sequence of hex digits with spaces between values. For instance, in the following hex dump, each 8-bit byte is a 2-digit hex number, with spaces between them, while the 32-bit offset at the start is an 8-digit hex number.

Identification There are several conventions for expressing that a number is represented as hex.

A decimal subscript can give the base explicitly. For example 15910 indicates decimal 159, 15916 indicates hex 159. Some prefer a text subscript, such as 159decimal and 159hex, or 159d and 159h In C and many languages influenced by it, the prefix 0x indicates that the numeric literal after it is in hex, a character of a string or character literal can be expressed as hex with the prefix \x (for example '\x1B' represents the Esc control character) and to output an integer as hex via printf-like function, the format conversion code %X or %x is used In URIs (including URLs), character codes are written as hex pairs prefixed with %: http://www.example.com/name%20with%20spaces where %20 is the code for the space (blank) character, ASCII code point 20 in hex, 32 in decimal. In XML and XHTML, a character can be expressed as a hex numeric character reference using the notation &#xcode;, for instance T represents the character U+0054 (the uppercase letter "T"). If there is no x the number is decimal (thus T is the same character). In Intel-derived assembly languages and Modula-2, hex is denoted with a suffixed H or h: FFh or 05A3H. Some implementations require a leading zero when the first hex digit character is not a decimal digit, so one would write 0FFh instead of FFh. Some other implementations (such as NASM) allow C-style numbers (0x42) Other assembly languages (6502, Motorola), Pascal, Delphi, some versions of BASIC (Commodore), GameMaker Language, Godot and Forth use $ as a prefix: $5A3, $C1F27ED Some assembly languages (Microchip) use the notation H'ABCD' (for ABCD16); similarly, Fortran 95 uses Z'ABCD' Ada and VHDL enclose hex numerals in based "numeric quotes": 16#5A3#, 16#C1F27ED#. For bit vector constants VHDL uses the notation x"5A3", x"C1F27ED". Verilog represents hex constants in the form 8'hFF, where 8 is the number of bits in the value and FF is the hex constant The Icon and Smalltalk languages use the prefix 16r: 16r5A3 PostScript and the Bourne shell and its derivatives denote hex with prefix 16#: 16#5A3, 16#C1F27ED Common Lisp uses the prefixes #x and #16r. Setting the variables *read-base* and *print-base* to 16 can also be used to switch the reader and printer of a Common Lisp system to hex representation for reading and printing numbers. Thus hex numbers can be represented without the #x or #16r prefix code, when the input or output base has been changed to 16. MSX BASIC, QuickBASIC, FreeBASIC and Visual Basic prefix hex numbers with &H: &H5A3 BBC BASIC and Locomotive BASIC use & for hex TI-89 and 92 series uses a 0h prefix: 0h5A3, 0hC1F27ED ALGOL 68 uses the prefix 16r to denote hex numbers: 16r5a3, 16rC1F27ED. Binary, quaternary (base-4), and octal numbers can be specified similarly. The most common format for hex on IBM mainframes (zSeries) and midrange computers (IBM i) running the traditional OS's (zOS, zVSE, zVM, TPF, IBM i) is X'5A3' or X'C1F27ED', and is used in Assembler, PL/I, COBOL, JCL, scripts, commands and other places. This format was common on other (and now obsolete) IBM systems as well. Occasionally quotation marks were used instead of apostrophes. Donald Knuth used a typewriter typeface to represent hex in his book The TeXbook, like: 5A3, C1F27ED

Implicit In some contexts, a number is always written as hex, and therefore, needs no identification notation.

In the Unicode standard, a character value is represented with U+ followed by the hex value, e.g. U+00A1 is the inverted exclamation point (¡). Color references in HTML, CSS and X Window can be expressed with six hex digits (two each for the red, green and blue components, in that order) prefixed with #: magenta, for example, is represented as #FF00FF. CSS also allows 3-hexdigit abbreviations with one hexdigit per component: #FA3 abbreviates #FFAA33, a golden orange. In MIME (e-mail extensions) quoted-printable encoding, character codes are written as hex pairs prefixed with =: Espa=F1a is "España" (F1hex is the code for ñ in the ISO/IEC 8859-1 character set).) PostScript binary data (such as image pixels) can be expressed as unprefixed consecutive hex pairs: AA213FD51B3801043FBC ... Any IPv6 address can be written as eight groups of four hex digits (sometimes called hextets), where each group is separated by a colon (:). This, for example, is a valid IPv6 address: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 or abbreviated by removing leading zeros as 2001:db8:85a3::8a2e:370:7334 (IPv4 addresses are usually written in decimal). Globally unique identifiers are written as thirty-two hex digits, often in unequal hyphen-separated groupings, for example 3F2504E0-4F89-41D3-9A0C-0305E82C3301.

Alternative symbols

Notable other hexadecimal representations that use symbols other than letters "A" through "F" to represent the digits above 9 include:

… excerpt ends here. Continue reading the full article.

Illustrations

Hexadecimal: Ronald O. Whitaker's hex notation proposal.[13][14]
Ronald O. Whitaker's hex notation proposal.[13][14]
Hexadecimal illustration
Hexadecimal: Hex finger-counting scheme
Hex finger-counting scheme
Hexadecimal: The programmable RPN-calculator HP-16C Computer Scientist from 1982 was designed for programmers. One of its key features was the conversion between different numeral systems (note hex number in display).
The programmable RPN-calculator HP-16C Computer Scientist from 1982 was designed for programmers. One of its key features was the conversion between different numeral systems (note hex number in display).
Hexadecimal: A hex multiplication table
A hex multiplication table

Worked examples

Example 1 — a first encounter with Hexadecimal

Start with the simplest possible case. Write down what Hexadecimal claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hexadecimal before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hexadecimal ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hexadecimal

In research
Hexadecimal appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hexadecimal in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hexadecimal is common in secondary-school and first-year university syllabi. It links to neighbouring topics Binary arithmetic, Hexadecimal numeral system, Positional numeral systems, so understanding it makes those chapters shorter.
In everyday life
Look for Hexadecimal outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Hexadecimal” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Hexadecimal in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hexadecimal means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hexadecimal out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hexadecimal in simple terms?

Hexadecimal (hex for short) is a positional numeral system for representing a numeric value as base 16. For the most common convention, a digit is represented as "0" to "9" like for decimal and as a letter of the alphabet from "A" to "F" (either upper or lower case) for the digits with decimal valu…

Why does Hexadecimal matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hexadecimal?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hexadecimal.

Tags

  • Binary arithmetic
  • Hexadecimal numeral system
  • Positional numeral systems
  • Power-of-two numeral systems

Keep exploring