Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Bitwise Functions. ---PLEASE HELP!
Message
 
 
To
12/10/2001 14:29:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00567866
Message ID:
00567878
Views:
23
>I am trying to use VFP's native bitwise functions to recreate something that was written in another language, namely Visual Objects. The problem is that VFP's bitwise functions return different values than Visual objects. JFYI, the function is called CRCFill, which fills a table with values returned from using bitwise functions. The only thing that I can see that is different in VO's method right off the bat is that VO requires variable typing and all of the vars in this particular method are created as ShortINT
>
>But let me explain what I mean about the differing values...I did the following in VFP6:
>
>lcTest = 1
>lcTest = bitlshift(lcTest,8) && lcTest now equals 256
>lcTest = bitlshift(lcTest,1) && lcTest now equals 512
>lcTest = bitlshift(lcTest,1) && lcTest now equals 1024
>lcTest = bitlshift(lcTest,1) && lcTest now equals 2048
>lcTest = bitlshift(lcTest,1) && lcTest now equals 4096
>lcTest = bitlshift(lcTest,1) && lcTest now equals 8192
>lcTest = bitlshift(lcTest,1) && lcTest now equals 16384
>lcTest = bitlshift(lcTest,1) && lcTest now equals 32768
>
>The above equivalant functions created in Visual Objects return the same values, UNTIL you get to the last one, which instead of returning 32768, it returns -32768....??
>
>Any ideas why VFP's bitwise functions return different values, and how I can get them to return the same values as VO? Thanks. -Jeff

Jeff,
Short Int has a range of -32768 to 32767. bitlshift(1,15) = 2^15 = 32768 so it falls outside of that range. Can you change the data type to something that will encompass the necessary range? Possibly long which can go to 2^31-1 (2,147,483,647).

Either that or check the return value from VFP and if greater than 2^15-1 (32767) then use the formula:

-(2^16) + MyValueHere

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform