R/dec2bin.R

#' conversion from decimal to binary
#'
#' \code{dec2bin(x)} converts decimal to binary
#'
#' @param x is a number

dec2bin<-function(X) {
  b=0
  while(X%%2^b!=X)b=b+1
  a<-2^((b-1):0)
  b<-2*a
  print(sapply(X,function(Z) paste(as.integer((Z %% b)>=a),collapse="")),quote=FALSE)
}
helophilus/ColsTools documentation built on May 30, 2019, 4:03 p.m.