binary: Treating binary and g-adic numbers

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

View source: R/binary.R

Description

Allows the access to individual digits in binary (and general g-adic) numbers.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
binary(x,mb=max(maxBit(x,g)),g=2)
unbinary(x,g=2)
bit(x,b,g=2)                       
## S3 method for class 'numeric'
bit(x,b=0:maxBit(x,g),g=2)
## S3 method for class 'character'
bit(x,b=0:maxBit(x,g),g=2)
bit(x,b,g=2) <- value                      
## S3 replacement method for class 'numeric'
bit(x,b=0:maxBit(x,g),g=2) <- value
## S3 replacement method for class 'character'
bit(x,b=0:maxBit(x,g),g=2) <- value
maxBit(x,g=2)
## S3 method for class 'numeric'
maxBit(x,g=2)
## S3 method for class '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))

Arguments

x

a number either represented a g-adic character string or as a integeral numeric value

b

the indicies of the bits to be processes. The least significant bit has index 0.

mb

maximal bit. The index of the most significant bit to be treated

g

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.

value

a vector of bit values to be selected or setted.

values

a vector of bit values that should be considered as TRUE.

...

some binary numbers

Details

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.

Value

binary

returns a standard binary (or g-adic) character representation of the number

unbinary

returns a binary (or g-adic) representation of the number

bit

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.

maxBit

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.

bitCount

returns the g-adic crossfoot of the number. For a binary number this is the number of bits set

gsi.orSum

Only works for binary numbers and does a parallel or on each of the bits for a list of binary numbers.

whichBits

returns the indices of the bits acutally set (or more precisely of the bits with value in values)

binary2logical

returns the a true false vector of the bits acutally set (or more precisely of the bits with value in values)

Author(s)

K.Gerald v.d. Boogaart http://www.stat.boogaart.de

See Also

outlierplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
(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

compositions documentation built on May 30, 2017, 3:25 a.m.