Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP Bitwise Functions. ---PLEASE HELP!
Message
 
 
À
12/10/2001 16:55:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00567866
Message ID:
00568026
Vues:
71
>Again... I feel like an idiot.... Your explanation was way over my head. I'm not sure how to apply your suggestions in the original example I gave. Larry suggested that I do the following if the value is greater than 32767
>
>-(2^16) + lcTest
>
>How would you change that? -Jeff
>p.s. sorry to be a pest.

Here's Bitlshift16 function that works for Short Int ( 16 bit) Values
FUNCTION  Bitlshift16
LPARAMETERS tnNumber, tnShift
LOCAL lnRetNumber
* Perform shift left
lnRetNumber = Bitlshift(tnNumber, tnShift)
* Clear anyting beyond lower 16 bit
lnRetNumber = Bitand( lnRetNumber, 0xFFFF)
* Check leftmost bit (sign) 
IF Bittest(lnRetNumber,15)
    * it's 16 bit negative number 
    lnRetNumber = -(2^16) + lnRetNumber
ENDIF
RETURN lnRetNumber
The leftmost bit in 16 bit Short Int is a sign bit. If it's 0 than number is positive. If it's 1 than number is negative and stored in the two's complement form.
-1 = 0xFFFF
-32768 = 0x8000
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform