The BASE function in Google Sheets is a powerful tool for converting numeric values into their textual representation in alternative numeral systems. This function is particularly useful in fields like computer science and mathematics, where different bases are frequently utilized. By leveraging the BASE function, users can effortlessly switch between decimal, binary, and hexadecimal formats, among others.
Syntax
BASE(number, base, [min_length])
- number: The numeric value that you wish to convert.
- base: The base system to which the number will be converted (an integer from 2 to 36).
- [min_length]: (Optional) The minimum length of the resulting string. If the result is shorter, it will be padded with leading zeros.
Example #1
=BASE(10, 2)
The function converts the decimal number 10 into its binary representation, resulting in ‘1010’.
Example #2
=BASE(255, 16)
This example converts the decimal number 255 into hexadecimal format, providing the result ‘FF’.
Example #3
=BASE(5, 3, 4)
Here, the function transforms the decimal number 5 into base 3, padding it to a minimum length of 4 characters, yielding ‘0012’.
Error handling
- NUM! This error occurs if the specified base is less than 2 or greater than 36, which are the valid range limits.
- VALUE! This error is shown when the number parameter is not a valid number, meaning it cannot be converted.
- REF! This error can occur if a referenced cell in the parameters is not valid or available.