http://asktom.oracle.com/pls/ask ... TERIA:272815731791,
The easiest is to use an undocumented (but heavily used -- check out the data
dictionary views, they use it all over the place so it won't be going away
anytime soon) function BITAND().Consider: [email protected]> declare
2nnumber;
3begin
4n := random.rand_max( power(2,31) );
5
5dbms_output.put_line( 'Number is ' || n ||
6
' ' || to_bin(n) );
7for j in 0 .. 30 loop
8
dbms_output.put( 'The ' || to_char(j+1) ||
9
'''th bit is ' );
10
if ( bitand( n, power(2,j) ) = power(2,j) )
11
then
12
dbms_output.put_line( 'on' );
13
else
14
dbms_output.put_line( 'off' );
15
end if;
16end loop;
17end;
18/