-- In this case since the significant bits -- are 0 and 1, the AND operation is -- between 0 and 1. -- BITAND(1,1) = 1 and other three -- combination (0,0), (0,1) and (1,0) -- result in 0 -- Refer Logic Gates (AND truth table) SELECT BITAND(0,0) bitand_00, BITAND(0,1) bitand_01, BITAND(1,0) bitand_10, BITAND(1,1) bitand_11 FROM DUAL;
-- For other input values, they get -- converted to binary values and -- the rightmost bit values are -- used in the AND operation. SELECT q_tab.x, BITAND(q_tab.x,q_tab.x) "BITAND(X,X)", BITAND(q_tab.x,q_tab.x-1) "BITAND(X,X-1)", BITAND(q_tab.x,0) "BITAND(X,0)", BITAND(q_tab.x,1) "BITAND(X,1)" FROM (SELECT level x FROM DUAL CONNECT BY level <=10 ) q_tab; -- Refer BITAND(X, X) Analysis -- Refer BITAND(X, X-1) Analysis -- Refer BITAND(X, 1) Analysis -- Any value of X with 0 in -- BITAND(X, 0) results in 0 -- as shown in the output of -- above query.
74093