The R Project SVN R

Rev

Rev 68948 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68948 Rev 72302
Line 1... Line 1...
1
% File src/library/base/man/octmode.Rd
1
% File src/library/base/man/octmode.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 2012 R Core Team
3
% Copyright 2016-2017 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{bitwise}
6
\name{bitwise}
7
\alias{bitwNot}
7
\alias{bitwNot}
8
\alias{bitwAnd}
8
\alias{bitwAnd}
Line 43... Line 43...
43
  coercion) or an invalid shift.
43
  coercion) or an invalid shift.
44
}
44
}
45
\seealso{
45
\seealso{
46
  The logical operators, \code{\link{!}},  \code{\link{&}},
46
  The logical operators, \code{\link{!}},  \code{\link{&}},
47
  \code{\link{|}}, \code{\link{xor}}.
47
  \code{\link{|}}, \code{\link{xor}}.
-
 
48
  Notably these \emph{do} work bitwise for \code{\link{raw}} arguments.
48
 
49
 
49
  The classes \code{"octmode"} and \code{"hexmnode"} whose
50
  The classes \code{"\link{octmode}"} and \code{"\link{hexmode}"} whose
50
  implementation of the standard logical operators is based on these
51
  implementation of the standard logical operators is based on these
51
  functions.
52
  functions.
52
 
53
 
53
  Package \pkg{bitOps} has similar functions for numeric vectors which
54
  Package \CRANpkg{bitops} has similar functions for numeric vectors which
54
  differ in the way they treat integers \eqn{2^{31}}{2^31} or larger.
55
  differ in the way they treat integers \eqn{2^{31}}{2^31} or larger.
55
}
56
}
56
 
57
 
57
\examples{
58
\examples{
-
 
59
bitwNot(0:12) # -1 -2  ... -13
58
bitwAnd(15L, 7L)
60
bitwAnd(15L, 7L) #  7
59
bitwOr(15L, 7L)
61
bitwOr (15L, 7L) # 15
60
bitwXor(15L, 7L)
62
bitwXor(15L, 7L) #  8
61
bitwXor(-1L, 1L)
63
bitwXor(-1L, 1L) # -2
-
 
64
 
-
 
65
## The "same" for 'raw' instead of integer :
-
 
66
rr12 <- as.raw(0:12) ; rbind(rr12, !rr12)
-
 
67
c(r15 <- as.raw(15), r7 <- as.raw(7)) #  0f 07
-
 
68
r15 & r7    # 07
-
 
69
r15 | r7    # 0f
-
 
70
xor(r15, r7)# 08
62
 
71
 
63
bitwShiftR(-1, 1:31) # shifts of 2^32-1 = 4294967295
72
bitwShiftR(-1, 1:31) # shifts of 2^32-1 = 4294967295
64
}
73
}
65
 
74
 
66
\keyword{logic}
75
\keyword{logic}