bin2hex {BMS} | R Documentation |
A simple-to-use function for converting a logical ('binary') vector into hex code and reverse.
bin2hex(binvec) hex2bin(hexcode)
binvec |
a logical vector (alternatively a vector coercible into logical) |
hexcode |
a single-element character denoting an integer in hexcode (admissible character: 0 to 9, ato f) |
The argument is an integer in binary form (such as "101"), provided as a logical (c(T,F,T)
) or numeric vector (c(1,0,1)
).
bin2hex
then returns a character denoting this number in hexcode (in this case "5").
The function hex2bin
does the reverse operation, e.g. hex2bin("5")
gives (c(1,0,1)
).
bin2hex
returns a single element character; hex2bin
returns a numeric vector equivalent to a logical vector
Martin Feldkircher and Stefan Zeugner
hex2bin
for converting hexcode into binary vectors, format.hexmode
for a related R function.
Check http://bms.zeugner.eu for additional help.
bin2hex(c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE)) bin2hex(c(1,0,1,0,1,1)) hex2bin("b8a") bin2hex(hex2bin("b8a"))