Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Bitwise Functions. ---PLEASE HELP!
Message
From
14/10/2001 13:58:39
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
14/10/2001 12:26:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00567866
Message ID:
00568302
Views:
15
>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)

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform