"Hanke, Alex" <[EMAIL PROTECTED]> wrote:
        I can produce the hex(a)decimal equivalent of a decimal number
        but I am having a hard time reversing the operation.

There are bound to be better ways, but perhaps the most obvious method
is
    (1) Break the string into single characters.
    (2) Match them up against the hexadecimal digits.
    (3) Multiply each digit by the appropriate power of 16.
    (4) Add 'em up.

hexdigits <- c("0","1","2","3","4","5","6","7",
               "8","9","A","B","C","D","E","F")

fromhex <- function (s) {
    s <- match(strsplit(s, "")[[1]], hexdigits) - 1
    sum(s * 16 ^ ((length(s)-1) : 0))
}

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to