Vector Bitops {vectorbitops}R Documentation

Bitwise Operations along a Vector

Description

Functions to apply the same bitwise operation sequentially down a vector of integers. A fast way to AND or OR everything together when a single value is required.

Usage

bit_vector_AND(vec)

bit_vector_OR(vec)

bit_vector_XOR(vec)

Arguments

vec

A vector of integers. Numeric vectors will be coerced to int.

Value

A single integer, the result of applying the operation in question along the vector. Input that cannot be coerced to int returns NA. An empty vector returns 0.

bit_vector_AND: A single integer, the result of ANDing each entry in the input vector together.

bit_vector_OR: A single integer, the result of ORing each entry in the input vector together.

bit_vector_XOR: A single integer, the result of XORing each entry in the input vector together.

Examples

bit_vector_AND(c(1,3,5,7,9))
bit_vector_OR(c(1,2,4,8,16))
bit_vector_XOR(c(1,2,3,4,5))

[Package vectorbitops version 1.1.2 Index]