Sign in to follow this  
Followers 0
Hiyoal

Hex To Binary

3 posts in this topic

Hey guys,

I dont know how I could do this because there is no function in autoit to convert a Hex Value to A Binary Value.

These are my 2 binary values:

CODE
$1=6A0F8BCE8BD8A3D62C4E00E93DD9F9FF

$2=E9B4260600

How can I do this???

Ive tried converting the hex to a string and then the string into a binary but it is in a completely different value than what binaries are usually in.

Ive gone on google and used a hex 2 binary converter and $1 returned: 01100010110001001110000000001110100100111101110110100000000000000000

and $2 returned: 1110100110110100001001100000011000000000

Please help.

Hiyoal

Share this post


Link to post
Share on other sites



Try this one:

Func HexToBin($i)
$j = StringSplit($i,"")
$output = ""
For $k = 1 To $j[0]
    Select
    Case $j[$k] = "A"
        $j[$k] = 10
    Case $j[$k] = "B"
        $j[$k] = 11
    Case $j[$k] = "C"
        $j[$k] = 12
    Case $j[$k] = "D"
        $j[$k] = 13
    Case $j[$k] = "E"
        $j[$k] = 14
    Case $j[$k] = "F"
        $j[$k] = 15
    EndSelect
    
    If $j[$k] >= 8 Then
        $j[$k] -= 8
        $output = $output & 1
    Else
        $output = $output & 0
    EndIf
    If $j[$k] >= 4 Then
        $j[$k] -= 4
        $output = $output & 1
    Else
        $output = $output & 0
    EndIf
    If $j[$k] >= 2 Then
        $j[$k] -= 2
        $output = $output & 1
    Else
        $output = $output & 0
    EndIf
    If $j[$k] >= 1 Then
        $j[$k] -= 1
        $output = $output & 1
    Else
        $output = $output & 0
    EndIf
Next
return $output
EndFunc

I tried to make it as understandable as possible. And it seems your online converter didn't convert $1 properly, mine is correct though.

Share this post


Link to post
Share on other sites

Thx heaps for that!!!!

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