Hi Dragan,
< snip >
>You only have to take care of BitLShift(), because BITAND( ),BITCLEAR( ), BITOR( ) , BITSET( ), BITTEST( ) and BITXOR( ) will not produce more bits in the result than there were in the operands. It would be true if foxpro kept results as 16 bit integers.
Keep in mind that BITNOT( ) will produce a 32-bit complement of your integer, i.e. if in 16 bit arithmetic bitnot(0) will be 0x0000ffff, in 32-bit it will be 0xffffffff. Also, doing Bitor() and BitXor() where one operand may be negative or above 32767, will yield numbers outside of the 16-bit range. The safe thing to do (if you want to keep it 16-bit) is to strip the upper 16 bits:
>
>function bitor16(n1,n2)
>return bitand(bitor(n1,n2), 0x0000ffff)
>
>function bitxor16(n1,n2)
>return bitand(bitxor(n1,n2), 0x0000ffff)Here's the test
lnNumber = BitLshift16( 1, 15)
? Bitand(Bitxor( lnNumber, 0), 0xffff)
--sb--