1% File src/library/base/man/hexmode.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2014 R Core Team 4% Distributed under GPL 2 or later 5 6\name{hexmode} 7\alias{as.hexmode} 8\alias{format.hexmode} 9\alias{print.hexmode} 10\alias{as.character.hexmode} 11\alias{[.hexmode} 12\alias{!.hexmode} 13\alias{|.hexmode} 14\alias{&.hexmode} 15%% FIXME: xor() is not generic (yet?). 16%% \alias{xor.hexmode} 17\alias{hexmode} 18\title{Display Numbers in Hexadecimal} 19\description{ 20 Convert or print integers in hexadecimal format, with as many digits 21 as are needed to display the largest, using leading zeroes as 22 necessary. 23} 24\usage{ 25as.hexmode(x) 26 27\method{as.character}{hexmode}(x, \dots) 28 29\method{format}{hexmode}(x, width = NULL, upper.case = FALSE, \dots) 30 31\method{print}{hexmode}(x, \dots) 32} 33\arguments{ 34 \item{x}{An object, for the methods inheriting from class \code{"hexmode"}.} 35 \item{width}{\code{NULL} or a positive integer specifying the minimum 36 field width to be used, with padding by leading zeroes.} 37 \item{upper.case}{a logical indicating whether to use upper-case 38 letters or lower-case letters (default).} 39 \item{\dots}{further arguments passed to or from other methods.} 40} 41\details{ 42 Class \code{"hexmode"} consists of integer vectors with that class 43 attribute, used merely to ensure that they are printed in hex. 44 45 If \code{width = NULL} (the default), the output is padded with 46 leading zeroes to the smallest width needed for all the non-missing 47 elements. 48 49 \code{as.hexmode} can convert integers (of \link{type} \code{"integer"} or 50 \code{"double"}) and character vectors whose elements contain only 51 \code{0-9}, \code{a-f}, \code{A-F} (or are \code{NA}) to class 52 \code{"hexmode"}. 53 54 There is a \code{\link{!}} method and methods for \code{\link{|}} and 55 \code{\link{&}}: 56 %% FIXME: xor() is not generic (yet?). 57 %% and \code{\link{xor}}: 58 these recycle their arguments to the length of the longer and then 59 apply the operators bitwise to each element. 60} 61\seealso{ 62 \code{\link{octmode}}, \code{\link{sprintf}} for other options in 63 converting integers to hex, \code{\link{strtoi}} to convert hex 64 strings to integers. 65} 66\examples{ 67i <- as.hexmode("7fffffff") 68i; class(i) 69identical(as.integer(i), .Machine$integer.max) 70 71hm <- as.hexmode(c(NA, 1)); hm 72as.integer(hm) 73} 74\keyword{utilities} 75\keyword{print} 76