AutoItKing Posted June 20, 2007 Share Posted June 20, 2007 I've tried Hex(), obviously... But it gives me wacko stuff. 0101 1010 should output 5A. But it doesn't. 101 should go to 5, yet it goes to 65... Huh? Any help? http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
the_lord_mephy Posted June 20, 2007 Share Posted June 20, 2007 That's because the Hex function is seeing your number as an integer, so instead of seeing 101 as binary, it's seeing the number one-hundred and one. There might be some sort of notation you have to put binary numbers in. I'll keep looking. My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
AutoItKing Posted June 20, 2007 Author Share Posted June 20, 2007 That's what I thought too, I tried a bunch of different ways of doing it. http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2007 Share Posted June 20, 2007 I've tried Hex(), obviously... But it gives me wacko stuff. 0101 1010 should output 5A. But it doesn't. 101 should go to 5, yet it goes to 65... Huh? Any help?I stops at the break (space) and reads it as decimal, not binary: 10110 = 0x65AuotIt does not seem to support the notation "0b01011010" for a binary nuber. (See help file under Data Types) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Developers Jos Posted June 20, 2007 Developers Share Posted June 20, 2007 $BinIn = "01011010" $Bits = StringSplit($BinIn,"") $Dec = 0 For $x = $Bits[0] To 1 Step -1 $dec += (2^($Bits[0]-$x)) * $Bits[$x] Next $hex = Hex($dec) ConsoleWrite("bin:" & $BinIn & " Dec:" & $dec & " Hex:" & $Hex & @CRLF) SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
AutoItKing Posted June 20, 2007 Author Share Posted June 20, 2007 That works! Thanks JdeB, you're so smart! :suckup: http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
the_lord_mephy Posted June 20, 2007 Share Posted June 20, 2007 lol I shoulda refreshed i just made UDF for it Func BinaryToHex($bin) Dim $hex, $thex, $num $bins = StringSplit($bin, " ") For $i = 1 to $bins[0] If StringLen($bins[$i]) <> 4 Then MsgBox(0, "", $bins[$i]) Return -1 EndIf $nums = StringSplit($bins[$i], "") $thex = 0 If $nums[1] = 1 Then $thex = $thex + 8 If $nums[2] = 1 Then $thex = $thex + 4 If $nums[3] = 1 Then $thex = $thex + 2 If $nums[4] = 1 Then $thex = $thex + 1 $num = $num & StringRight(Hex($thex), 1) Next Return $num EndFunc MsgBox(0, "", BinaryToHex("0101 1010")) My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
AutoItKing Posted June 20, 2007 Author Share Posted June 20, 2007 I like that one! Now on to the rest of my program.... Mwahahaha!! http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now