A to Z of Excel Functions: the BASE Function
21 October 2016
Welcome back to our regular A to Z of Excel Functions blog. Today we look at the BASE function.
The BASE function
This function converts a number into a text representation with the given radix (base). Clear as mud if you speak gobbledygook.
What does it mean in English? BASE converts a number in decimal (base 10) to a different base (which is known as the radix). Let me provide an example. Take the number 37. In base 3, this can be represented as:
(1 x 33) + (1 x 32) + (0 x 31) + (1 x 30)
= (1 x 27) + (1 x 9) +(0 x 3) + (1 x 1)
= 27 + 9 + 0 + 1
So in base 3 this is the text representation 1101. If we needed this representation to be of minimum length (min_length) 8, then
27 = (0 x 37) + (0 x 36) + (0 x 35) + (0 x 34) + (1 x 33) + (1 x 32) + (0 x 31) + (1 x 30)
Makes sense now?
The BASE function has only been around since Excel 2013 so it will not work in earlier versions of Excel. It employs the following syntax to operate:
BASE(number, radix, [min_length])
The BASE function has the following arguments:
- number: this is required and represents the number that you want to convert. This must be an integer greater than or equal to 0 and less than 253
- radix: this is also required and represents the base radix that you want to convert the number into. This must be an integer greater than or equal to 2 and less than or equal to 36 (why 36??)
- min_length: this is optional. This represents minimum length of the returned string and must be an integer greater than or equal to zero if specified.
It should be further noted that:
- If number, radix, or min_length are outside the minimum or maximum constraints, BASE returns the #NUM! error value
- If number is a non-numeric value, BASE returns the #VALUE! error value
- Any non-integer number entered as an argument is truncated to an integer
- If the min_length argument is included, leading zeros are added to the result if the result would otherwise be shorter than the minimum length specified. For example, BASE(16,2) returns 10000, but BASE(16,2,8) returns 00010000
- The maximum value of the min_length argument is 255.
Please see my example below:
We’ll continue our A to Z of Excel Functions soon. Keep checking back – there’s a new blog post every other business day.