[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stange things
[Thread Prev] | [Thread Next]
- Subject: Re: Stange things
- From: Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
- Date: Wed, 11 Sep 2024 19:55:31 +0300
- To: user@xxxxxxxxxxxxxxxxxxxxxx
I think IIF evaluates both options, before assigning the value to the iDigitVal. Thus the byte is overflown (it cannot take negative values). Use integer type, or do not use IIF. Jussi On Wed, Sep 11, 2024 at 5:04 PM Fabien Bodard <gambas.fr@xxxxxxxxx> wrote: > Hi, > > > with this function : > > Public Sub Base34Decoder(Value As String) As Long > > Dim lResult As Long > Dim iDigitVal, i As Integer > Dim aNum As Byte[] = Byte[].FromString(UCase(Value)).Reverse() > > For i = 0 To aNum.Max > iDigitVal = IIf(aNum[i] >= Asc("2") And aNum[i] <= Asc("9"), aNum[i] - > 50, aNum[i] - 57) > lResult += iDigitVal * (34 ^ i) > Next > > Return lResult > > End > > Public sub Main() > Print Utils.Base34Decoder("3BG73G") > end > > I get "Dépassement de Capacité" on the line <iDigitVal = IIf(aNum[i] >= > Asc("2") And aNum[i] <= Asc("9"), aNum[i] - 50, aNum[i] - 57)> > > > Why ??? > > Thank you for your help :-) > > > > -- > Fabien Bodard >
Stange things | Fabien Bodard <gambas.fr@xxxxxxxxx> |