>Hi Sergey,
>
>Thanks for the shiftlbit16 function. I have so little understanding of bitwise functions. I notice in this VO code that there the programmer used Bitwise Shift-Right, BitAnd, and Exclusive OR. Will I need to write/obtain corresponding 16-bit functions for those three functions as well, since he's using short-int Vars? If so do you have any that are public domain or can you direct me to them? Thanks. -Jeff
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. 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)