Convert a bits object to an integer and vice versa

bits2int(x)

int2bits(i, n_bit = 16)

Arguments

x

the bits object

i

the integer

n_bit

the number of bits

See also

Other bits: as.character.bits(), bits(), c.bits(), print.bits()

Author

Thierry Onkelinx

Examples

z <- bits(c(FALSE, TRUE, TRUE, FALSE))
z
#> 0110
y <- bits2int(z)
y
#> [1] 6
int2bits(y)
#> 0000000000000110
int2bits(y, 4)
#> 0110