Jump to content



Photo

Hex to Decimal


  • Please log in to reply
3 replies to this topic

#1 redndahead

redndahead

    Wishing autoIT was part of windows.

  • Active Members
  • PipPipPipPipPipPip
  • 471 posts

Posted 19 January 2004 - 06:16 PM

I see there is a way of turning Decimal to Hex. Is there a way to turn it back from Hex to Decimal?

red





#2 tylo

tylo

    Universalist

  • Developers
  • 280 posts

Posted 19 January 2004 - 07:31 PM

Not built in, but you can feed the string from Hex() back into this func:
Func Hex2Dec($number)   $len = StringLen($number)   $number = StringUpper($number)   $ret = 0   $fac = 1   For $i = $len To 1 Step -1     $n = Asc(StringMid($number, $i, 1)) - 48     If $n > 9 Then $n = $n - 7     $ret = $ret + ($n * $fac)     $fac = $fac * 16   Next   Return $ret EndFunc

/EDIT: removed use of ^ operator: Jon, this is straight forward to do in C. :whistle:

Edited by tylo, 20 January 2004 - 07:02 AM.

blub

#3 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,529 posts

Posted 19 January 2004 - 07:55 PM

I should make that built in really.

This list is getting longer. Arrgrgh.

#4 redndahead

redndahead

    Wishing autoIT was part of windows.

  • Active Members
  • PipPipPipPipPipPip
  • 471 posts

Posted 19 January 2004 - 10:48 PM

Thanks Tylo that was exactly what i needed...

I would appreciate it jon that will cut out some unnecessary code.

Thanks everybody again. Give my password encryption program a try.

red




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users