# bin: Sundry binary functionality In partitions: Additive Partitions of Integers

## Description

Utilities to convert things to binary

## Usage

 ```1 2 3 4``` ```tobin(n, len, check=TRUE) todec(bin) comptobin(comp, check=TRUE) bintocomp(bin, use.C=TRUE, check=TRUE) ```

## Arguments

 `n` Integer, to be converted to binary by function `tobin()` `len` Length of the binary vector returned by function `tobin()` `bin` Binary: a vector of `0`s and `1`s `comp` A composition `check` Boolean, with default `TRUE` meaning to perform various checks `use.C` Boolean, with default `TRUE` meaning to use `C`

## Details

These functions are not really intended for the end user; they are used in `nextcomposition()`.

• Function `tobin()` converts integer `n` to a binary string of length `len`

• Function `todec()` converts a binary string to decimal, so `todec(tobin(n,i))==n`, provided `i` is big enough

• Function `comptobin()` converts a composition to binary

• Function `bintocomp()` converts a binary string to a composition

## Author(s)

Robin K. S. Hankin

## References

Wikipedia 2008. “Composition (number theory) — Wikipedia, The Free Encyclopedia”, http://en.wikipedia.org/w/index.php?title=Composition_(number_theory)&oldid=243080178; Online; accessed 3-February-2009

## Examples

 ```1 2 3 4``` ```tobin(10,5) todec(tobin(10,5)) comptobin(c(1,1,4)) bintocomp(c(1,1,0,0,1,1,1,1)) ```

partitions documentation built on July 7, 2017, 9:03 a.m.