Category: FUNCTION | Updated: 2026-11-22

How to Use the BASE Function in Google Sheets | Convert Decimal Numbers to Binary or Hexadecimal

How to Use the BASE Function

The BASE function is a Google Sheets math function that converts a non-negative decimal integer into a text representation in a specified base (radix from 2 to 36).

Syntax

=BASE(value, base, [min_length])
  • value: The decimal number (an integer greater than or equal to 0) to convert (required).
  • base: The target base (radix), specified as an integer from 2 to 36 (required).
  • min_length: The minimum length of the returned string. Leading 0s are added if the result is shorter than this length (optional).

Examples

Here is an example of converting decimal numbers into binary, hexadecimal (such as for color codes), and base 36.

Row Column A (Decimal) Column B (Target Base) Column C (Formula) Column D (Result)
1 Decimal Target Base Formula Result
2 10 Binary =BASE(A2, 2) 1010
3 10 Binary (8 digits) =BASE(A3, 2, 8) 00001010
4 255 Hexadecimal =BASE(A4, 16) FF
5 35 Base 36 =BASE(A5, 36) Z
  • Explanation: Specifying 8 as the third argument (row 3) makes it easy to generate zero-padded 8-bit representations commonly used in software development and networking.

Common Errors and Tips

  • Negative numbers or out-of-range bases cause #NUM!: Passing a negative number for value or a base less than 2 or greater than 36 returns a #NUM! error.
  • Decimals are truncated: If value or base contains a fractional part, it is automatically truncated to an integer.
  • The return value is a text string: Because BASE outputs text, you cannot perform arithmetic directly on binary or hexadecimal results. Use the DECIMAL function to convert them back to base 10.

Frequently Asked Questions

Q. What range of bases can I specify in the BASE function?

A. You can specify any integer from base 2 to base 36 (2–36). For bases greater than 10, the letters "A–Z" are used in addition to "0–9".

Q. How do I zero-pad the result to a fixed length (e.g., 00001010)?

A. Specify the desired length in the third argument, "min_length". For example, "=BASE(10, 2, 8)" returns the 8-digit binary string "00001010".