Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary to/from Decimal
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00418552
Message ID:
00418580
Views:
38
>>>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.


Thank you,

I just typed this directly form scratch in the message.
So i did't test it.
Sorry and thanks again,
Previous
Reply
Map
View

Click here to load this message in the networking platform