BASE in Excel: Create Binary, Hexadecimal and Padded Text Codes
Use Excel BASE for radix conversion, leading-zero padding, integer limits and auditable label construction.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: BASE converts a nonnegative number into a text representation in a chosen base from 2 through 36. =BASE(45,2,8) is expected to return 00101101 as text.
Availability and version history
- Introduced: Original introduction release not established by the official history reviewed.
- Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Checked: October 14, 2026; official BASE reference. Examples are independently calculated expectations, not native Excel test results.
Syntax and defaults
=BASE(number, radix, [min_length])
number is the value being represented; radix selects the number system. The optional min_length sets a minimum output width, adding leading zeros when necessary. Omitting it produces an unpadded representation. It does not set a maximum width or truncate a longer result. Official BASE reference
The documented number domain is from zero up to, but not including, 2^53. Radix must be between 2 and 36. A supplied minimum length must be from 0 through 255. Microsoft documents truncation of fractional arguments to integers, #NUM! for constraints outside their allowed limits and #VALUE! for a nonnumeric number argument.
Example 1: show one quantity in several bases
=BASE(45,2)
=BASE(45,8)
=BASE(45,16)
=BASE(45,36)
Expected text results: 101101, 55, 2D, 19. All four strings represent decimal 45; the underlying quantity did not change.
The hexadecimal result uses D for digit value 13: 2×16+13 = 45. The base-36 result uses two digits because 1×36+9 = 45. Keep a radix label beside exported strings so a recipient does not interpret 19 as decimal nineteen.
Example 2: create a fixed-width binary display
Enter 0, 1, 45, 128 in A2:A5. In B2 enter and fill down:
=BASE(A2,2,8)
Expected B2:B5:
| Decimal input | Expected text |
|---|---|
| 0 | 00000000 |
| 1 | 00000001 |
| 45 | 00101101 |
| 128 | 10000000 |
These are eight-character representations for these inputs, not a promise that BASE enforces an eight-bit range. =BASE(256,2,8) is expected to return 100000000, containing nine characters.
If the destination requires exactly eight binary digits, validate the original whole number as 0 through 255 separately. Padding cannot enforce that rule.
Example 3: fractional arguments are truncated
=BASE(31.9,16.8,4.9)
Expected result: 001F. For this positive-input example, the arguments become 31, 16 and 4 before conversion. The discarded fractional portion is not rounded up.
A workflow that requires whole-number identifiers should reject fractional source data instead of relying on truncation. Otherwise distinct inputs such as 31.1 and 31.9 can produce the same text code.
Advanced example: construct and check a hexadecimal label
Suppose A2 contains the fictional sequence number 2748. To create a readable label:
="BIN-"&BASE(A2,16,4)
Expected result: BIN-0ABC. The arithmetic check is 10×16²+11×16+12 = 2748. The prefix and padding are presentation choices; they do not encrypt the sequence or make it unpredictable.
For a second value of 4096, the result becomes BIN-1000. For 65536, it becomes BIN-10000, showing again why minimum length is not a maximum-field-width constraint.
When constructing labels, keep the numeric source in its own column. Stripping a prefix later is more fragile than retaining a clean source number alongside the display label.
Advanced example: protect a two-digit hexadecimal field
For a numeric input in A2, a field accepting only whole numbers 0 through 255 can use:
=IF(AND(A2>=0,A2<=255,A2=INT(A2)),BASE(A2,16,2),"Review number")
Expected results for 15, 255, 256, 15.5 are 0F, FF, Review number, Review number. This guard is intentionally scoped to numeric inputs; it is not an all-purpose imported-text validator. AND combines the domain checks, while INT tests whole-number equality here.
BASE performs positional numeral conversion, not a signed two’s-complement encoding. Do not feed a negative number into it expecting a machine-specific bit pattern.
Text, precision and common mistakes
The result is text even when it contains only digits. Preserve that type when exporting padded codes; automatic numeric conversion can remove leading zeros. =LEN(BASE(45,2,8)) is expected to return 8, a simple output-width check using LEN.
Use the actual numeric source, not a rounded visual display, to decide whether an input is in range. A cell format can hide fractional values without removing them. Large imported numeric strings may already have lost precision before BASE sees them, so BASE cannot restore discarded digits.
Test zero, a typical value, a width boundary and a value just beyond your own business limit. The function’s broad numeric range is different from the narrower range your label format may permit.
Verification: Fictional inputs and independently calculated outputs; no native Excel execution. See the editorial testing standards.