base2dec | R Documentation |
base2dec
converts a sequence of numeric symbols (digits)
from some base notation to decimal (i.e., base 10) notation.
base2dec(x, base = 2)
x |
A (required) sequence of numeric symbols (as a sequence or vector of digits). |
base |
The base of the symbols in |
Individual digits (e.g., 0-9) must exist in the specified base (i.e., every digit value must be lower than the base value).
base2dec
is the complement of dec2base
.
An integer number (in decimal notation).
dec2base
converts decimal numbers into another base;
as.roman
converts integers into Roman numerals.
Other numeric functions:
dec2base()
# (a) single string input:
base2dec("11") # default base = 2
base2dec("0101")
base2dec("1010")
base2dec("11", base = 3)
base2dec("11", base = 5)
base2dec("11", base = 10)
# (b) numeric vectors as inputs:
base2dec(c(0, 1, 0))
base2dec(c(0, 1, 0), base = 3)
# (c) character vector as inputs:
base2dec(c("0", "1", "0"))
base2dec(c("0", "1", "0"), base = 3)
# (d) multi-digit vectors:
base2dec(c(1, 1))
base2dec(c(1, 1), base = 3)
# Special cases:
base2dec(NA)
base2dec(0)
base2dec(c(3, 3), base = 3) # Note message!
# Note:
base2dec(dec2base(012340, base = 5), base = 5)
dec2base(base2dec(043210, base = 5), base = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.