Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,10 @@
# Since R 3.0.0, the base package provides bitwise operators, see ?bitwAnd
a <- 35
b <- 42
bitwAnd(a, b)
bitwOr(a, b)
bitwXor(a, b)
bitwNot(a)
bitwShiftL(a, 2)
bitwShiftR(a, 2)

View file

@ -0,0 +1,5 @@
a <- as.hexmode(35)
b <- as.hexmode(42)
as.integer(a & b) # 34
as.integer(a | b) # 43
as.integer(xor(a, b)) # 9

View file

@ -0,0 +1,13 @@
intToLogicalBits <- function(intx) as.logical(intToBits(intx))
logicalBitsToInt <- function(lb) as.integer(sum((2^(0:31))[lb]))
"%AND%" <- function(x, y)
{
logicalBitsToInt(intToLogicalBits(x) & intToLogicalBits(y))
}
"%OR%" <- function(x, y)
{
logicalBitsToInt(intToLogicalBits(x) | intToLogicalBits(y))
}
35 %AND% 42 # 34
35 %OR% 42 # 42

View file

@ -0,0 +1,8 @@
library(bitops)
bitAnd(35, 42) # 34
bitOr(35, 42) # 43
bitXor(35, 42) # 9
bitFlip(35, bitWidth=8) # 220
bitShiftL(35, 1) # 70
bitShiftR(35, 1) # 17
# Note that no bit rotation is provided in this package