powered by
Utilities to convert things to binary
tobin(n, len, check=TRUE) todec(bin) comptobin(comp, check=TRUE) bintocomp(bin, use.C=TRUE, check=TRUE)
Integer, to be converted to binary by function tobin()
tobin()
Length of the binary vector returned by function tobin()
Binary: a vector of 0s and 1s
0
1
A composition
Boolean, with default TRUE meaning to perform various checks
TRUE
Boolean, with default TRUE meaning to use C
C
Robin K. S. Hankin
These functions are not really intended for the end user; they are used in nextcomposition().
nextcomposition()
Function tobin() converts integer n to a binary string of length len
n
len
Function todec() converts a binary string to decimal, so todec(tobin(n,i))==n, provided i is big enough
todec()
todec(tobin(n,i))==n
i
Function comptobin() converts a composition to binary
comptobin()
Function bintocomp() converts a binary string to a composition
bintocomp()
Wikipedia contributors, 2020. “Composition (combinatorics) --- Wikipedia, The Free Encyclopedia”, https://en.wikipedia.org/w/index.php?title=Composition_(combinatorics)&oldid=944285378
tobin(10,5) todec(tobin(10,5)) comptobin(c(1,1,4)) bintocomp(c(1,1,0,0,1,1,1,1))
Run the code above in your browser using DataLab