bit (version 1.1-15.1)

as.logical.bit: Coercion from bit, bitwhich and ri to logical, integer, double

Description

Coercing from bit to logical, integer, which.

Usage

# S3 method for bit
as.logical(x, …)
# S3 method for bitwhich
as.logical(x, …)
# S3 method for ri
as.logical(x, …)
# S3 method for bit
as.integer(x, …)
# S3 method for bitwhich
as.integer(x, …)
# S3 method for ri
as.integer(x, …)
# S3 method for bit
as.double(x, …)
# S3 method for bitwhich
as.double(x, …)
# S3 method for ri
as.double(x, …)

Arguments

x

an object of class bit, bitwhich or ri

ignored

Value

as.logical returns a vector of FALSE, TRUE, as.integer and as.double return a vector of 0,1.

Details

Coercion from bit is quite fast because we use a double loop that fixes each word in a processor register.

See Also

as.bit, as.which, as.bitwhich, as.ff, as.hi

Examples

Run this code
# NOT RUN {
  x <- ri(2, 5, 10)
  y <- as.logical(x)
  y
  stopifnot(identical(y, as.logical(as.bit(x))))
  stopifnot(identical(y, as.logical(as.bitwhich(x))))

  y <- as.integer(x)
  y
  stopifnot(identical(y, as.integer(as.logical(x))))
  stopifnot(identical(y, as.integer(as.bit(x))))
  stopifnot(identical(y, as.integer(as.bitwhich(x))))

  y <- as.double(x)
  y
  stopifnot(identical(y, as.double(as.logical(x))))
  stopifnot(identical(y, as.double(as.bit(x))))
  stopifnot(identical(y, as.double(as.bitwhich(x))))
# }

Run the code above in your browser using DataLab