SELECT TO_NUMBER('FF', 'XX'), TO_CHAR(255, 'XX') FROM DUAL;

TO_NUMBER('FF','XX') TO_CHAR(255,'XX')
-------------------- -----------------
                 255  FF             






SELECT  LEVEL AS NUM
,       DECODE(BITAND(LEVEL, 128), 128, 1, 0)
||      DECODE(BITAND(LEVEL,  64),  64, 1, 0)
||      DECODE(BITAND(LEVEL,  32),  32, 1, 0)
||      DECODE(BITAND(LEVEL,  16),  16, 1, 0)
||      ' '
||      DECODE(BITAND(LEVEL,   8),   8, 1, 0)
||      DECODE(BITAND(LEVEL,   4),   4, 1, 0)
||      DECODE(BITAND(LEVEL,   2),   2, 1, 0)
||      DECODE(BITAND(LEVEL,   1),   1, 1, 0) AS BIT
FROM DUAL
CONNECT BY LEVEL <= 128;


       NUM BIT                 
---------- --------------------
         1 0000 0001           
         2 0000 0010           
         3 0000 0011           
         4 0000 0100           
         5 0000 0101           
         6 0000 0110           
         7 0000 0111           
         8 0000 1000           
         9 0000 1001           
        10 0000 1010