% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bit.R, R/generics.R
\name{as.bit.NULL}
\alias{as.bit.NULL}
\alias{as.bit.bit}
\alias{as.bit.logical}
\alias{as.bit.integer}
\alias{as.bit.double}
\alias{as.bit.bitwhich}
\alias{as.bit.which}
\alias{as.bit.ri}
\alias{as.bit}
\title{Coercing to bit}
\usage{
\method{as.bit}{`NULL`}(x, ...)

\method{as.bit}{bit}(x, ...)

\method{as.bit}{logical}(x, ...)

\method{as.bit}{integer}(x, ...)

\method{as.bit}{double}(x, ...)

\method{as.bit}{bitwhich}(x, ...)

\method{as.bit}{which}(x, length = attr(x, "maxindex"), ...)

\method{as.bit}{ri}(x, ...)

as.bit(x = NULL, ...)
}
\arguments{
\item{x}{an object of class \code{\link[=bit]{bit()}}, \code{\link[=logical]{logical()}},
\code{\link[=integer]{integer()}}, \code{\link[=bitwhich]{bitwhich()}} or an integer from
\code{\link[=as.which]{as.which()}} or a boolean \code{\link[ff:vmode]{ff}}}

\item{...}{further arguments}

\item{length}{the length of the new bit vector}
}
\value{
\code{is.bit} returns FALSE or TRUE, \code{as.bit} returns a vector
of class 'bit'
}
\description{
Coercing to bit vector
}
\details{
Coercing to bit is quite fast because we use a double loop that fixes each
word in a processor register
}
\section{Methods (by class)}{
\itemize{
\item \code{as.bit(`NULL`)}: method to coerce to \code{\link[=bit]{bit()}} (zero length) from \code{\link{NULL}}

\item \code{as.bit(bit)}: method to coerce to \code{\link[=bit]{bit()}} from \code{\link[=bit]{bit()}}

\item \code{as.bit(logical)}: method to coerce to \code{\link[=bit]{bit()}} from \code{\link[=logical]{logical()}}

\item \code{as.bit(integer)}: method to coerce to \code{\link[=bit]{bit()}} from
\code{\link[=integer]{integer()}} (\code{0L} and \code{NA} become \code{FALSE},
everthing else becomes \code{TRUE})

\item \code{as.bit(double)}: method to coerce to \code{\link[=bit]{bit()}} from
\code{\link[=double]{double()}} (\code{0} and \code{NA} become \code{FALSE}, everthing
else becomes \code{TRUE})

\item \code{as.bit(bitwhich)}: method to coerce to \code{\link[=bit]{bit()}} from \code{\link[=bitwhich]{bitwhich()}}

\item \code{as.bit(which)}: method to coerce to \code{\link[=bit]{bit()}} from \code{\link[=as.which]{which()}}

\item \code{as.bit(ri)}: method to coerce to \code{\link[=bit]{bit()}} from \code{\link[=ri]{ri()}}

}}
\note{
Zero is coerced to FALSE, all other numbers including NA are coerced
to TRUE.  This differs from the NA-to-FALSE coercion in package ff and may
change in the future.
}
\examples{
as.bit(c(0L, 1L, 2L, -2L, NA))
as.bit(c(0, 1, 2, -2, NA))

as.bit(c(FALSE, NA, TRUE))

}
\seealso{
\code{\link{CoercionToStandard}}, \code{\link[=as.booltype]{as.booltype()}}, \code{\link[=as.bit]{as.bit()}},
\code{\link[=as.bitwhich]{as.bitwhich()}} , \code{\link[=as.which]{as.which()}}, \code{\link[=as.ri]{as.ri()}}, \code{\link[ff:as.hi]{ff::as.hi()}},  \code{\link[ff:as.ff]{ff::as.ff()}}
}
\author{
Jens Oehlschlägel
}
\keyword{classes}
\keyword{logic}
