Welcome back to our usual blog of Excel functions from A to Z. Today we look at the BASE function.
The BASE function
This function converts a number in a text representation with the given base. Clear as mud if you speak nonsense.
What does it mean in english? BASE convert a number in decimal (base 10) to a different base (which is known as the base). Let me give you 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
Then on base 3 this is the text representation 1101. If we needed this representation to have a minimum length (Minimum length) 8, subsequently
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)
= 00001101.
Does it make sense now?
The BASE The function has only existed since Excel 2013, so it won't work in older versions of Excel. Use the following syntax to operate:
BASE (number, base, [min_length])
The BASE The function has the following arguments:
- number: this is mandatory and represents the number you want to convert. Must be an integer greater than or equal to 0 and less than 253
- base: this is also required and represents the base base you want to convert the number to. It must be an integer greater than or equal to 2 and less than or equal to 36 (why 36 ??)
- Minimum length: this is optional. This represents the minimum length of the returned string and must be an integer greater than or equal to zero if specified.
It should be noted at the same time that:
- And number, base, O Minimum length are outside the minimum or maximum restrictions, BASE return the #ON ONE! error value
- And number is a non-numeric value, BASE return the #VALUE! error value
- Any number that is not an integer entered as an argument is truncated to an integer.
- If he Minimum length If an argument is included, leading zeros are added to the result if, opposite case, the result would be shorter than the specified minimum length. As an example, BASE (16,2) bring back 10000, but BASE (16,2,8) bring back 00010000
- The maximum value of the Minimum length the argument is 255.
Please, see my example below: