Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

BITAND with 64bit integer

618993Jan 22 2008 — edited Jan 22 2008
<font face="Courier New"
SQL> declare <br>
2 b number;<br>
3 begin<br><br>
4 select bitand(power(2,62),power(2,62)) into b from dual;<br>
5 dbms_output.put_line('2 power 62(63bit number)='||power(2,62)||' Output of BITAND operation='||b);<br><br>
6 select bitand(power(2,63),power(2,63)) into b from dual;<br>
7 dbms_output.put_line('2 power 63(64bit number)='||power(2,63)||' Output of BITAND operation='||b);<br><br>
8 select bitand(power(2,64),power(2,64)) into b from dual;<br>
9 dbms_output.put_line('2 power 64(65bit number)='||power(2,64)||' Output of BITAND operation='||b);<br><br>
10 end;<br>
11 /<br><br>
2 power 62(63bit number)=4611686018427387904 Output of BITAND operation=4611686018427387904<br>
2 power 63(64bit number)=9223372036854775808 Output of BITAND operation=9223372036854775807<br>
2 power 64(65bit number)=18446744073709551616 Output of BITAND operation=9223372036854775807<br>
<br><br>
PL/SQL procedure successfully completed.<br><br>
</font>
Question:<br>
The BITAND function works fine till 63 bit number. But it gives out incorrect result for 64 bit number and beyond. Please throw

some light on why this is happening like this and how to overcome this.
<br><br>
Version: Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
<br><br>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2008
Added on Jan 22 2008
8 comments
783 views