Allows the access to individual digits in binary (and general g-adic) numbers.
binary(x,mb=max(maxBit(x,g)),g=2)
unbinary(x,g=2)
bit(x,b,g=2)
# S3 method for numeric
bit(x,b=0:maxBit(x,g),g=2)
# S3 method for character
bit(x,b=0:maxBit(x,g),g=2)
bit(x,b,g=2) <- value
# S3 method for numeric
bit(x,b=0:maxBit(x,g),g=2) <- value
# S3 method for character
bit(x,b=0:maxBit(x,g),g=2) <- value
maxBit(x,g=2)
# S3 method for numeric
maxBit(x,g=2)
# S3 method for character
maxBit(x,g=2)
bitCount(x,mb=max(maxBit(x,g)),g=2)
gsi.orSum(...,g=2)
whichBits(x,mb=max(maxBit(x,g)),g=2,values=c(TRUE))
binary2logical(x,mb=max(maxBit(x,g)),g=2,values=c(TRUE))
returns a standard binary (or g-adic) character representation of the number
returns a binary (or g-adic) representation of the number
returns the values of the requested bits. The values are returned as a logical vector for binary numbers an as numeric digit values for other g-adic numbers.
returns the most significant bit represented in the number. This is the highest bit set in numeric numbers and the highest actually given character in a character representation.
returns the g-adic crossfoot of the number. For a binary number this is the number of bits set
Only works for binary numbers and does a parallel or on each of the bits for a list of binary numbers.
returns the indices of the bits acutally set (or more
precisely of the bits with value in values
)
returns the a true false vector of the bits
acutally set (or more
precisely of the bits with value in values
)
a number either represented a g-adic character string or as a integeral numeric value
the indicies of the bits to be processes. The least significant bit has index 0.
maximal bit. The index of the most significant bit to be treated
the base of the g-adic representation. 2 corresponds to binary numbers, 8 to octal numbers, 16 to hexadecimal numbers. g is limited by 36.
a vector of bit values to be selected or setted.
a vector of bit values that should be considered as TRUE.
some binary numbers
K.Gerald v.d. Boogaart http://www.stat.boogaart.de
These routines are primerily intended to manipulate g-adic numbers for user interface purposes and condensed representation of information. They are not intended for a long number arithmetic.
outlierplot
(x<-unbinary("10101010"))
(y<-binary(x))
bit(x,1:3)
bit(y,0:3)
maxBit(x)
maxBit(y)
whichBits(x)
whichBits(y)
binary2logical(y)
bit(x)
bit(y)
gsi.orSum(y,1)
bitCount(x)
bitCount(y)
bit(x,2)<-1
x
bit(y,2)<-1
y
Run the code above in your browser using DataLab