Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

intToBin

Converts an integer to a binary/octal/hexadecimal number


Description

Converts an integer to a binary/octal/hexadecimal number.

Usage

intToBin(x)
 intToOct(x)
 intToHex(x)

Arguments

x

A numeric vector of integers to be converted.

Details

For length(x) > 1, the number of characters in each of returned elements is the same and driven by the x element that requires the highest number of character - all other elements are padded with zeros (or ones for negative values). This is why we for instance get intToHex(15) == "f" but intToHex(15:16) == c("0f", "10").

The supported range for intToHex(), intToOct(), and intToBin() is that of R integers, i.e. [-.Machine$integer.max, +.Machine$integer.max] where. .Machine$integer.max is 2^31-1. This limitation is there such that negative values can be converted too.

Value

Returns a character string of length length(x). For coercions out of range, NA_character_ is returned for such elements.

Author(s)

Henrik Bengtsson


R.utils

Various Programming Utilities

v2.10.1
LGPL (>= 2.1)
Authors
Henrik Bengtsson [aut, cre, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.