Saturday, February 4, 2017

Decimal, Binary, Octal, Hexadecimal table

library(data.table)
library(R.utils)
print(setnames(data.table(cbind(2^0:128,intToBin(2^0:128),intToOct(2^0:128),intToHex(2^0:128))),c("Decimal","Binary","Oct","Hex"))[1:100])
     Decimal   Binary Oct Hex
  1:       1 00000001 001  01
  2:       2 00000010 002  02
  3:       3 00000011 003  03
  4:       4 00000100 004  04
  5:       5 00000101 005  05
  6:       6 00000110 006  06
  7:       7 00000111 007  07
  8:       8 00001000 010  08
  9:       9 00001001 011  09
 10:      10 00001010 012  0a
....
 t1 <- setnames(data.table(cbind(2^0:128,intToBin(2^0:128),intToOct(2^0:128),intToHex(2^0:128))),c("Decimal","Binary","Oct","Hex")) t1
     Decimal   Binary Oct Hex
  1:       1 00000001 001  01
  2:       2 00000010 002  02
  3:       3 00000011 003  03
  4:       4 00000100 004  04
  5:       5 00000101 005  05
 ---                         
124:     124 01111100 174  7c
125:     125 01111101 175  7d
126:     126 01111110 176  7e
127:     127 01111111 177  7f
128:     128 10000000 200  80
sapply(t1,class)
    Decimal      Binary         Oct         Hex 
"character" "character" "character" "character"