Learn R Programming

bitstreamio (version 0.1.0)

bits_to_uint: Convert between bits and unsigned integers

Description

Convert between bits and unsigned integers

Usage

bits_to_uint(bits, nbits = NULL)

uint_to_bits(x, nbits)

Value

logical vector of bit values of vector of unsigned integers

Arguments

bits

logical vector of bit values in MSB first order

nbits

number of bits per integer. If NULL, then bits is assumed to represent a single integer value. If not NULL, then the number of values in bits must be a multiple of nbits

x

vector of unsigned integers

Examples

Run this code
bits <- uint_to_bits(c(1, 2, 3), nbits = 3)
bits
bits_to_uint(bits, nbits = 3)

Run the code above in your browser using DataLab