Sign in to follow this  
Followers 0
redndahead

Hex to Decimal

4 posts in this topic

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

red

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

blub

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0