[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stange things


Il 11/09/24 16:03, Fabien Bodard ha scritto:
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

Written like this, could it work?
Dim aNum As Short[] = Byte[].FromString(UCase(Value)).Reverse()
Algebra will remain a mystery to me.

Regards
Gianluigi


References:
Stange thingsFabien Bodard <gambas.fr@xxxxxxxxx>