Learn R Programming

cwhmisc (version 6.0)

int2: convert integers, string to integer wector

Description

Functions for conversion of integers to bases other than decimal

Usage

intToASCII(i) intToBase( i, base=2 ) intToOct( i ) intToHex( i )

Arguments

i,base
Integer

Details

isNumeric Test whether the elements of a character vector represent legal numbers only. intToASCII Show character or octal representation at a place in the ASCII sequence. intToBase Convert an integer number to string representation in a base between 2 and 16 inclusive. intToOct Convert integer to octal representation. intToHex Convert integer to hex representation. contfrac Convert to continued fraction representation. evalcfr Evaluate continued fraction to corresponding real. toFrac Build rational approximation num/den to x using forward continued fraction recursion to a depth of depth. Stopping criterion: either depth is reached, or abs(x - num/den) is increasing again. toFrac2 same as toFrac, but vectors of partial numerators and denominators are returned. xToBase return res$a, res$e so that x = a*base^e, abs( a ) in [1, base)

Examples

Run this code
intToASCII(1:255)[121:129] # "x"   "y"   "z"   "{"   "|"   "}"   "~"   "\177" "\200"
sapply(1:50,intToBase,2)
sapply(1:50,intToBase,7)
sapply(1:50,intToOct)
sapply(1:50,intToHex)

Run the code above in your browser using DataLab