Coercing to bit vector

# S3 method for class '`NULL`'
as.bit(x, ...)

# S3 method for class 'bit'
as.bit(x, ...)

# S3 method for class 'logical'
as.bit(x, ...)

# S3 method for class 'integer'
as.bit(x, ...)

# S3 method for class 'double'
as.bit(x, ...)

# S3 method for class 'bitwhich'
as.bit(x, ...)

# S3 method for class 'which'
as.bit(x, length = attr(x, "maxindex"), ...)

# S3 method for class 'ri'
as.bit(x, ...)

as.bit(x = NULL, ...)

Arguments

x

an object of class bit(), logical(), integer(), bitwhich() or an integer from as.which() or a boolean ff

...

further arguments

length

the length of the new bit vector

Value

is.bit returns FALSE or TRUE, as.bit returns a vector of class 'bit'

Details

Coercing to bit is quite fast because we use a double loop that fixes each word in a processor register

Methods (by class)

  • as.bit(`NULL`): method to coerce to bit() (zero length) from NULL

  • as.bit(bit): method to coerce to bit() from bit()

  • as.bit(logical): method to coerce to bit() from logical()

  • as.bit(integer): method to coerce to bit() from integer() (0L and NA become FALSE, everthing else becomes TRUE)

  • as.bit(double): method to coerce to bit() from double() (0 and NA become FALSE, everthing else becomes TRUE)

  • as.bit(bitwhich): method to coerce to bit() from bitwhich()

  • as.bit(which): method to coerce to bit() from which()

  • as.bit(ri): method to coerce to bit() from 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.

Author

Jens Oehlschlägel

Examples

as.bit(c(0L, 1L, 2L, -2L, NA))
#> bit length=5 occupying only 1 int32
#>     1     2     3     4     5 
#> FALSE  TRUE  TRUE  TRUE FALSE 
as.bit(c(0, 1, 2, -2, NA))
#> bit length=5 occupying only 1 int32
#>     1     2     3     4     5 
#> FALSE  TRUE  TRUE  TRUE FALSE 

as.bit(c(FALSE, NA, TRUE))
#> bit length=3 occupying only 1 int32
#>     1     2     3 
#> FALSE FALSE  TRUE