I'm working on a legacy database using bitmaps for searching. I'm using the
bitand function to find bitmaps that match a given bitmask but I'm getting the wrong results: the bitand between two numbers is returning a non-zero value when zero would be expected.
I'm using Oracle 11gR2 and I can reproduce the problem like this:
create table BITAND_TEST (BITMAP binary_double); -- insert the bitmap of 2^57 in the table insert into BITAND_TEST values (144115188075855872); -- bitand(2^57, 2^50) evaluates to 0 select bitand(144115188075855872, 1125899906842624) from dual; -- but in this statement it returns non-zero select * from BITAND_TEST where bitand(BITMAP, 1125899906842624) <> 0; -- I'm using 2^50 here
Is this a type casting problem? Which types would you use to store a bitmap?