Skip to content
Prev 382189 / 398502 Next

Converting Decimal numbers into Binary

Hello,


Your code and the answers provided, specially Marc's, led me to


utf8ToBin <- function(x, out = c("ascii", "dec", "bin")){
   out <- match.arg(out)
   ascii_datformat <- utf8ToInt(x)
   Base <- ascii_datformat - 48
   Base <- ifelse(Base > 40, Base - 8, Base)
   Bin <- R.utils::intToBin(Base)
   switch (out,
     "ascii" = ascii_datformat,
     "dec" = Base,
     "bin" = Bin
   )
}

utf8ToBin("133m@", out = "ascii")
utf8ToBin("133m@", out = "dec")
utf8ToBin("133m@", out = "bin")


Hope this helps,

Rui Barradas

?s 16:30 de 27/12/19, Paul Bernal escreveu: