Base Conversions | R Documentation |
These functions convert numbers from one base to another. There are several solutions for this problem out there, but the naming is quite heterogeneous and so consistent function names might be helpful.
BinToDec(x)
DecToBin(x)
OctToDec(x)
DecToOct(x)
HexToDec(x)
DecToHex(x)
x |
a vector of numbers, resp. alphanumerical representation of numbers (hex), to be converted. |
BinToDec converts numbers from binary mode into decimal values. DecToBin does it the other way round.
Oct means octal system and hex hexadecimal.
A numeric or character vector of the same length as x containing the converted values.
Binary, octal and decimal values are numeric, hex-values are returned as class hexmode
.
Andri Signorell <andri@signorell.net>
strtoi
DecToBin(c(17, 25))
BinToDec(c(101, 11101))
DecToOct(c(17, 25))
OctToDec(c(11, 77))
DecToHex(c(17, 25))
HexToDec(c("FF", "AA", "ABC"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.