bitAnd: Bitwise And, Or and Xor Operations

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/bitops.R

Description

Bitwise operations, ‘and’ (&), ‘or’ (|), and ‘Xor’ (xor).

Usage

1
2
3
4
5
6
bitAnd(a, b)
a %&% b
bitOr (a, b)
a %|% b
bitXor(a, b)
a %^% b

Arguments

a,b

numeric vectors of compatible length, each treated as 32 bit “strings”.

Details

The bitwise operations are applied to the arguments cast as 32 bit (unsigned long) integers. NA is returned wherever the magnitude of the arguments is not less than 2^31, or, where either of the arguments is not finite.

For bitwise ‘not’ (! in R), use bitFlip().

Value

non-negative integer valued numeric vector of maximum length of a or b.

Author(s)

Steve Dutky; idea for operators: Dan L Robertson

See Also

bitFlip, bitShiftL; further, cksum.

Examples

1
2
3
4
bitAnd(15,7) == 7 ;  identical(15 %&% 7, bitAnd(15, 7))
bitOr(15,7) == 15 ;  identical(15 %|% 7, bitOr (15, 7))
bitXor(15,7) == 8 ;  identical(15 %^% 7, bitXor(15,7))
bitOr(-1,0) == 4294967295 ; identical(-1 %|% 0, bitOr(-1,0))

bitops documentation built on April 24, 2021, 5:07 p.m.