In this video, I show how hexadecimal numbers work and how to use them in Business Central – ELI5 style.

In this video, Erik gives an “Explain It Like I’m Five” introduction to hexadecimal numbers — what they are, why they exist, and how to work with them in AL and Business Central. Inspired by a LinkedIn discussion that revealed some common misunderstandings about hex in the BC community, Erik walks through the fundamentals of number bases, binary, and hex encoding, then demonstrates how to convert values to hexadecimal using the Type Helper codeunit.
Why Talk About Hexadecimal?
Hexadecimal knowledge isn’t something most Business Central developers need every day, but it does come up — especially when working with encryption keys, binary data, or interacting with external systems that expect hex-encoded strings. A recent LinkedIn discussion showed that there are some common misconceptions in the BC community about how hex works, so Erik decided to create a primer.
Number Bases: A Quick Refresher
Base 10 (Decimal)
As humans, we naturally work in base 10. We have 10 fingers, so we use 10 digits (0–9). When we need to represent a number larger than 9, we add another digit position: 10, 15, 105, and so on. Each position represents a power of 10.
Base 2 (Binary)
Deep down, computers work in binary — base 2. The lowest unit is a bit, which is either 0 or 1. If you’ve ever seen images of old computers with rows of toggle switches, each of those switches represents a single bit.
Bits are grouped together into bytes. A byte is 8 bits, and it became the universal standard for representing characters and measuring storage (kilobytes, megabytes, gigabytes). In binary, a byte can represent values from 00000000 (0) to 11111111 (255).
Here’s how some small numbers look in binary:
- 0 =
00000000 - 1 =
00000001 - 2 =
00000010 - 3 =
00000011(1 + 2) - 7 =
00000111(1 + 2 + 4) - 15 =
00001111(1 + 2 + 4 + 8)
Base 16 (Hexadecimal)
A byte is traditionally viewed as two 4-bit groups, called the high nibble and the low nibble. Each nibble can represent values from 0 to 15. The problem is that in base 10, the number 15 requires two characters. We need a system where any nibble value can be represented by a single character.
Enter hexadecimal — base 16. Since we run out of numeric digits after 9, we extend the system using letters:
- 0–9 = same as decimal
- A = 10
- B = 11
- C = 12
- D = 13
- E = 14
- F = 15
This means any byte value (0–255) can be represented with exactly two hex characters. For example:
- 15 in decimal =
0Fin hex (one nibble maxed out) - 255 in decimal =
FFin hex (both nibbles maxed out) - 34 in decimal =
22in hex (2 × 16 + 2 = 34)
An important thing to remember: hex 22 is not “twenty-two” — it’s “two-two” in hex, which equals 34 in decimal. It’s very tempting to read it as a decimal number, but resist the urge!
From Hex to Binary and Back
One of the great advantages of hexadecimal is that you can easily convert between hex and binary, because each hex digit maps directly to exactly 4 bits. For example, hex 22:
2=00102=0010- So hex
22= binary00100010
If you ever need help, even the Windows Calculator has a “Programmer” mode that shows decimal, hex, and binary representations side by side.
Working with Hexadecimal in Business Central
The Type Helper Codeunit
Business Central provides a codeunit called Type Helper that includes a handy function: IntToHex. This converts an integer value to its hexadecimal string representation.
A quick note on why it’s “integer to hex” and not “decimal to hex”: hexadecimal is used to represent memory — whole numbers, byte values, bit patterns. There’s no concept of decimal points in hex (at least not in any practical computing context). So it only makes sense to convert integers.
Converting a String to Hex
Here’s a practical example: converting each character of a string into its hex representation. In AL, a string is essentially an array of characters, and each character has a numeric value. By looping through the string, converting each character to an integer, and then to hex, we can build a hex-encoded output string.
pageextension 50109 CustomerListExt extends "Customer List"
{
trigger OnOpenPage()
var
TypeHelper: Codeunit "Type Helper";
Input: Text;
Output: Text;
b: Integer;
I: Integer;
begin
Input := 'Youtube';
for i := 1 to strlen(Input) do begin
b := Input[i];
if b < 16 then
output += '0';
output += TypeHelper.IntToHex(b);
end;
Message('Input = %1, output = %2', Input, Output);
end;
}
There are a few things worth noting in this code:
- Character to integer conversion: You can't pass a
Chardirectly toIntToHex— you'll get an error like "unable to convert from System.Char to System.Int32." The workaround is to first assign the character to anIntegervariable (b := Input[i]), then pass that integer to the function. - Zero-padding: The
IntToHexfunction does not pad its output. If the value is less than 16 (i.e., it fits in a single hex digit), you'll get a one-character result like4instead of04. Theif b < 16check manually prepends a zero to ensure each byte is always represented by two hex characters. This is important for keeping the output properly aligned and parseable. - Unicode caveat: Business Central uses Unicode (16-bit) characters, not 8-bit ASCII. For this example, all the characters in "Youtube" fall within the standard ASCII range (the first 128 values), so treating them as single bytes works fine. If you were dealing with characters outside this range, you'd need to handle multi-byte encoding.
Running this code produces output like: Input = Youtube, output = 596F757475626... — each pair of hex characters represents one letter of the input string.
A Note on Base64
Erik makes an important clarification: Base64 encoding is not the same as hexadecimal. Now that we understand base 2, base 10, and base 16, it might be tempting to think Base64 is just another number base — and conceptually it is, but it works quite differently in practice. Base64 uses 64 different characters (letters, numbers, and a couple of special characters) to pack more data into a readable text string. It's a completely different encoding scheme from hex, used for different purposes (like encoding binary data in email or JSON). Don't confuse the two!
Where Would You Use Hex in Business Central?
- Encryption keys: Keys are typically 256-bit or 512-bit values. The standard convention for displaying and exchanging these is as hexadecimal strings.
- Binary data inspection: When you need to examine raw bytes — from a stream, a file, or a blob — hex provides a compact, readable representation.
- Interfacing with external systems: Many APIs and protocols use hex-encoded values for identifiers, hashes, or binary payloads.
Summary
Hexadecimal is simply a base-16 number system that provides a human-friendly way to represent binary data. Each hex digit maps to exactly 4 bits, and two hex digits represent one byte. In Business Central, the Type Helper codeunit's IntToHex function makes it straightforward to convert integer values to hex strings. Just remember to handle zero-padding for values under 16, be aware of the char-to-integer conversion requirement, and don't confuse hexadecimal (base 16) with Base64 encoding — they're entirely different things.