Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary to/from Decimal
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00418552
Message ID:
00418572
Vues:
27
>>I am trying to convert a character field (which is really a character represetation of a binary number, for example, 01010) to decimal (in this case 10). Is there a built-in function in VFP that can do that?
>>
>>How about the reverse (going from decimal to binary)?
>

>Don't know about such a function but try this.
>Local lnTel,lenght,lcBin,lnDec
>lcBin="01010"
>lnLenght = Len(lcBin)
>For lnTel = 1 to lnLenght
>  lnDec = iif(SubStr(lcBin,lnLenght-lnTel+1,1)='1',BitSet(lnDec,lntel),lnDec)
>EndFor
>for the reverse you can do the same.

Only problem here is that it's off by one.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform