Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BitTest'ing numbers larger then 32 bits
Message
De
01/01/2021 17:09:00
 
 
À
01/01/2021 16:39:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01677684
Message ID:
01677706
Vues:
59
>>
>>There is no safe way for doing this in VFP using numeric types, I believe, as Dragan remarked.
>
>Ok, after playing around with Martina's solution, I discovered that you (Antonio) are right. The VFP64_BitTest routine does not provide the results I am looking for. But it does send me in the right direction.

Greg,

There is a 64bit division in VFP2C32.fll that you could use to extend the range of your flags beyond the lower 32.
PROCEDURE VFP64_BITTEST
LPARAMETERS m.nNumericExpression1, m.nBitNumber
RETURN IIF(m.nBitNumber<=31, ;
  BITTEST(m.nNumericExpression1, m.nBitNumber), ;
  BITTEST(VAL(Int64_Div(m.nNumericExpression1, 0x100000000, 2)), m.nBitNumber-32))
That said, going up closer to 64 bits, VFP starts to not being able to differentiate the numeric values properly. For instance,
? 18014398509481983 = 18014398509481984
returns .T., which is wrong, of course. That will give about 55 bits that can be stored as numeric values, but even those will require an external library to perform the calculations.

By using string binary data to hold the flags, you won't need external tools and won't be limited to 64 bits (you could easily escalate to 128, 256, and so on).
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform