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:
00418577
Vues:
33
>>Only problem here is that it's off by one.
>

>Sorry for not understanding, but what do you mean with this.

It yields the wrong result. In the example (01010) equals 10. Your method returns 20. Why? Because integers are base zero in the way they are numbered. However, the following does work
lndec = 0
lnLenght = Len(lcBin)
For lnTel = 1 to lnLenght
  lnDec = iif(SubStr(lcBin,lnLenght-lnTel+1,1)='1',BitSet(lnDec,lntel <b>- 1</b>),lnDec)
EndFor
Hence, you're 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