hexmode: Display Numbers in Hexadecimal

Description Usage Arguments Details See Also Examples

Description

Convert or print integers in hexadecimal format, with as many digits as are needed to display the largest, using leading zeroes as necessary.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as.hexmode(x)

## S3 method for class 'hexmode'
as.character(x, ...)

## S3 method for class 'hexmode'
format(x, width = NULL, upper.case = FALSE, ...)

## S3 method for class 'hexmode'
print(x, ...)

Arguments

x

An object, for the methods inheriting from class "hexmode".

width

NULL or a positive integer specifying the minimum field width to be used, with padding by leading zeroes.

upper.case

a logical indicating whether to use upper-case letters or lower-case letters (default).

...

further arguments passed to or from other methods.

Details

Class "hexmode" consists of integer vectors with that class attribute, used merely to ensure that they are printed in hex.

If width = NULL (the default), the output is padded with leading zeroes to the smallest width needed for all the non-missing elements.

as.hexmode can convert integers (of type "integer" or "double") and character vectors whose elements contain only 0-9, a-f, A-F (or are NA) to class "hexmode".

There is a ! method and |, & and xor methods: these recycle their arguments to the length of the longer and then apply the operators bitwise to each element.

See Also

octmode, sprintf for other options in converting integers to hex, strtoi to convert hex strings to integers.

Examples

1
2
3
4
5
6
i <- as.hexmode("7fffffff")
i; class(i)
identical(as.integer(i), .Machine$integer.max)

hm <- as.hexmode(c(NA, 1)); hm
as.integer(hm)

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.