hex2bin {BMS}R Documentation

Converting Binary Code to and from Hexadecimal Code

Description

A simple-to-use function for converting a logical ('binary') vector into hex code and reverse.

Usage

hex2bin(hexcode)

bin2hex(binvec)

Arguments

hexcode

a single-element character denoting an integer in hexcode (admissible character: 0 to 9, ato f)

binvec

a logical vector (alternatively a vector coercible into logical)

Details

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)).

Value

bin2hex returns a single element character; hex2bin returns a numeric vector equivalent to a logical vector

See Also

hex2bin for converting hexcode into binary vectors, format.hexmode for a related R function.

Check http://bms.zeugner.eu for additional help.

Examples


  bin2hex(c(TRUE,FALSE,TRUE,FALSE,TRUE,TRUE))
  bin2hex(c(1,0,1,0,1,1))
  hex2bin("b8a")
  bin2hex(hex2bin("b8a"))


[Package BMS version 0.3.5 Index]