BASE function

BASE(Number, Radix, MinimumLength?) BASE(Number; Radix; MinimumLength?)

Number

Number or { Number }

The number to convert.

Radix

Number or { Number }

The desired base (radix). Must be between 2 and 36 (inclusive).

MinimumLength

Number or { Number } (optional)

The minimum length of the returned string; it is padded with zeroes if necessary. If omitted, it is assumed to be 0, meaning that there is no length preference. If the minimum length is not 0, it must be a positive number.

Returns

Text or { Text }

A text representation of a converted number.

Returns a text representation of a number converted to a certain base (radix). BASE(9, 2)BASE(9; 2) returns "1001", which is the base 2 representation of 9 (8 * 1 + 4 * 0 + 2 * 0 + 1 * 18 * 1 + 4 * 0 + 2 * 0 + 1 * 1).

In most contexts, numbers use base 10, but other popular bases in engineering contexts include base 2 (binary), base 8 (octal) and base 16 (hexadecimal).

Use the DECIMAL function to convert a number in a different base to its base 10 representation. Also consider using the more specialized DEC2BIN, DEC2OCT and DEC2HEX functions.

Examples

BASE(9, 2)BASE(9; 2)

Returns "1001", which is the binary representation of 9.

BASE(7, 2)BASE(7; 2)

Returns "111", which is the binary representation of 7.

BASE(13, 2)BASE(13; 2)

Returns "1101", which is the binary representation of 13.

Returns "1001", which is the binary representation of 9.

BASE(13, 8)BASE(13; 8)

Returns "15", which is the octal representation of 13.

DEC2OCT(13)DEC2OCT(13)

Returns "15", which is the octal representation of 13.

BASE(13, 16)BASE(13; 16)

Returns "D", which is the hexadecimal representation of 13.

DEC2HEX(13)DEC2HEX(13)

Returns "D", which is the hexadecimal representation of 13.

BASE(13, { 2, 8, 16 })BASE(13; { 2; 8; 16 })

Returns the array { "1101", "15", "D" }{ "1101"; "15"; "D" }, containing the binary, octal and hexadecimal representation of 13, in that order.