hexmode {base}  R Documentation 
Integers which are displayed in hexadecimal (short ‘hex’) format, with as many digits as are needed to display the largest, using leading zeroes as necessary.
Arithmetic works as for integers, and noninteger valued mathematical functions typically work by truncating the result to integer.
as.hexmode(x)
## S3 method for class 'hexmode'
as.character(x, keepStr = FALSE, ...)
## S3 method for class 'hexmode'
format(x, width = NULL, upper.case = FALSE, ...)
## S3 method for class 'hexmode'
print(x, ...)
x 
an object, for the methods inheriting from class 
keepStr 
a 
width 

upper.case 
a logical indicating whether to use uppercase letters or lowercase letters (default). 
... 
further arguments passed to or from other methods. 
Class "hexmode"
consists of integer vectors with that class
attribute, used primarily to ensure that they are printed in hex.
Subsetting ([
) works too, as do arithmetic or
other mathematical operations, albeit truncated to integer.
as.character(x)
drops all attributes
(unless when
keepStr=TRUE
where it keeps, dim
, dimnames
and
names
for back compatibility) and converts each entry individually, hence with no
leading zeroes, whereas in format()
, when width = NULL
(the
default), the output is padded with leading zeroes to the smallest width
needed for all the nonmissing elements.
as.hexmode
can convert integers (of type "integer"
or
"double"
) and character vectors whose elements contain only
09
, af
, AF
(or are NA
) to class
"hexmode"
.
There is a !
method and methods for 
and
&
:
these recycle their arguments to the length of the longer and then
apply the operators bitwise to each element.
octmode
, sprintf
for other options in
converting integers to hex, strtoi
to convert hex
strings to integers.
i < as.hexmode("7fffffff")
i; class(i)
identical(as.integer(i), .Machine$integer.max)
hm < as.hexmode(c(NA, 1)); hm
as.integer(hm)
Xm < as.hexmode(1:16)
Xm # print()s via format()
stopifnot(nchar(format(Xm)) == 2)
Xm[16] # *no* leading zeroes!
stopifnot(format(Xm[16]) == c(1:9, letters[1:6]))
## Integer arithmetic (remaining "hexmode"):
16*Xm
Xm^2
Xm
(fac < factorial(Xm[1:12])) # !1, !2, !3, !4 .. in hexadecimals
as.integer(fac) # indeed the same as factorial(1:12)