Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary (base 2) - Decimal Conversion
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00114476
Message ID:
00114618
Vues:
13
Bruce,

I misread your first message, I didn't realize you wanted a bit string of 1s and 0s. It sounds like you'll be doing quite a lot of this function so you might consider using a lookup instead of doing so much bit/string manipulation
* define this once
dimension gaBits[256]
for i = 1 to 256
   gaBits[i] = BitPattern( i-1 )  && use one of the functions provided already
endfor

lcBits = Bits32( x ) && assuming x is a integer of 32 bits

function Bits16( pnNumber )
local lnMSB, lnLSB
lnMSB = int( pnNumber / 256 )  && most significant byte
lnLSB = pnNumber % 256  && least significant byte
return  gaBits[ lnMSB + 1 ] + gaBits[ lnLSB + 1 ]

function Bits32( pnNumber )
local lnMSW, lnLSW
lnMSW = int( pnNumber / 65536 )  && most significant word
lnLSW = pnNumber % 65536  && least significant word
return Bits16( lnMSW ) + Bits16( lnLSW )
>Thanks everyone, for the help. As I was hoping, I didn't need to reinvent the wheel :)
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform