Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Dec/Hex/Octal/Binary Table

 [1/1] from: mdb::gci::net at: 13-Dec-2000 14:19


REBOL [] numeric-equivalents: func [x [integer!] /local x1 x2] [ x1: x oct: copy "" while [x1 <> 0] [append oct x1 // 8 x1: to-integer x1 / 8] insert/dup tail oct 0 (3 - length? oct) reverse oct x1: x bin: copy "" while [x1 <> 0] [append bin x1 // 2 x1: to-integer x1 / 2] insert/dup tail bin 0 (8 - length? bin) reverse bin x2: to-string x insert/dup x2 " " (3 - length? x2) print reform [x2 remove/part to-string to-hex x 6 oct bin] ] for y 1 255 1 [numeric-equivalents y] produces the following output 1 01 001 00000001 2 02 002 00000010 3 03 003 00000011 4 04 004 00000100 5 05 005 00000101 6 06 006 00000110 7 07 007 00000111 8 08 010 00001000 9 09 011 00001001 10 0A 012 00001010 11 0B 013 00001011 ... 242 F2 362 11110010 243 F3 363 11110011 244 F4 364 11110100 245 F5 365 11110101 246 F6 366 11110110 247 F7 367 11110111 248 F8 370 11111000 249 F9 371 11111001 250 FA 372 11111010 251 FB 373 11111011 252 FC 374 11111100 253 FD 375 11111101 254 FE 376 11111110 255 FF 377 11111111