Documentation/Calc Functions/BASE

    From The Document Foundation Wiki
    Other languages:


    Function name:

    BASE

    Category:

    Text

    Summary:

    Converts a non-negative integer to a text representation in a specified base / radix. The minimum number of characters in the text representation can be specified, in which case leading zeroes are added if required. The characters 0-9 and uppercase A-Z are used as the “digits” in the returned text.

    The BASE function is complementary to the DECIMAL function.

    Note pin.svg

    Note
    This function is not related to the Base database management component of LibreOffice.

    Syntax:

    BASE(Number; Radix[; MinimumLength])

    Returns:

    Returns a text string representing the given number in the specified base / radix

    Arguments:

    Number is a non-negative integer, or a reference to a cell containing a non-negative integer, that is to be converted to a text representation.

    Radix is an integer in the range 2 ≤ r ≤ 36, or a reference to a cell containing such an integer, that is the base / radix to be used for the text representation.

    MinimumLength is a non-negative integer, or a reference to a cell containing a non-negative integer, that is the minimum number of characters to appear in the text representation. If MinimumLength is omitted, the returned text comprises the least number of characters without any leading zeroes. If a valid value of MinimumLength is specified but is less than or equal to the smallest number of characters needed, then it is ignored; leading zeroes are added if MinimumLength is valid and greater than the smallest number of characters needed.

    • If any of Number, Radix, or MinimumLength is non-numeric, then BASE reports a #VALUE! error.
    • For any non-integer value of Number, Radix, or MinimumLength, BASE truncates the value to an integer.
    • If, after any truncation, either Number or MinimumLength is less than 0, then BASE reports an invalid argument error (Err:502).
    • If, after any truncation, Radix is less than 2 or greater than 36, then BASE reports an invalid argument error (Err:502).

    Additional details:

    BASE generates text representations of non-negative integer numbers for any base in the range 2 to 36, using the 10 digits (0-9) and 26 uppercase letters (A-Z) of the modern English alphabet. The positional numeral systems for each base have been given names that are listed on Wikipedia's List of numeral systems page. Some of the more commonly used are:

    • Base 2 – binary, using the digits 0 and 1.
    • Base 8 – octal, using the digits 0 to 7.
    • Base 10 – decimal, using the digits 0 to 9.
    • Base 16 – hexadecimal, using the digits 0 to 9 and characters A (10) to F (15).
    • Base 32 – duotrigesimal, using the digits 0 to 9 and characters A (10) to V (31).
    • Base 36 – hexatrigesimal, using the digits 0 to 9 and characters A (10) to Z (35).

    For a non-negative integer x and a valid base b, note that x = DECIMAL(BASE(x; b); b).

    Examples:

    Formula Description Returns
    =BASE(15; 2) Here the function returns the text string "1111", representing the value of 15 in binary notation. 1111
    =BASE(15.6; 8.3; 4.8) Here the function returns the text string "0017", representing the value of 15 in octal notation with two leading zeroes. The values of all three arguments are truncated to integers. 0017
    =BASE(D1; D2; D3) where cells D1, D2, and D3 contain the values 56, 10, and 3 respectively. Here the function returns the text string "056", representing the value of 56 in decimal notation with a leading zero. 056
    =BASE(175; 16) Here the function returns the text string "AF", representing the value of 175 in hexadecimal notation. AF
    =BASE(351; 32) Here the function returns the text string "AV", representing the value of 351 in duotrigesimal (base 32) notation. AV
    =BASE(395; 36) Here the function returns the text string "AZ", representing the value of 395 in hexatrigesimal (base 36) notation. AZ

    Related LibreOffice functions:

    DECIMAL

    ODF standard:

    Section 6.19.3, part 2

    Related (or similar) Excel functions:

    BASE since v.2013.