ZeDMIN Posted September 13, 2004 Share Posted September 13, 2004 Hiya, i did not find any Script/Function to convert decimal values to binary strings and vice versa, so i just wrote them by myself. I don't know if anyone except me will ever need this, but maybe someone will find it helpful Func Dec2Bin($decimal) $binary = '' While $decimal>0 $binary = String(Mod($decimal, 2)) & $binary $decimal = Int($decimal/2) WEnd Return $binary EndFunc Func Bin2Dec($binary) $decimal = 0 For $i = 0 To StringLen($binary) Step 1 $decimal = $decimal + Number(StringMid($binary, StringLen($binary)-$i, 1))*(2^$i) Next Return $decimal EndFunc Please leave any comments, what you think about it (or just to let me know someone actually READ this post ). Greetings, ZeD Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 13, 2004 Share Posted September 13, 2004 Good Job! It appears to work. *** Matt @ MPCS Link to comment Share on other sites More sharing options...
JonathanChan Posted September 15, 2004 Share Posted September 15, 2004 Nice! Now if someone just had a hex to decimal to binary converter... Link to comment Share on other sites More sharing options...
ZeDMIN Posted September 15, 2004 Author Share Posted September 15, 2004 There is a Decimal to Hex and Hex to Decimal Converter implemented in AutoIT, named Hex() and Dec(). So you just can call Dec2Bin(Dec("FFFF")) or did you intend something else? Link to comment Share on other sites More sharing options...
ZeDMIN Posted September 16, 2004 Author Share Posted September 16, 2004 Hi again, i was bored, so i wrote the missing Converters, too. Now its capable to convert Decimal <-> Binary <-> Hexadecimal <-> Decimal I wonder if the implemented function "Hex()" looks similar to my "Dec2Hex()"? Anyways, mine doesnt put leading "0" on Hexadecimal Numbers. expandcollapse popupFunc Dec2Bin($decimal) $binary = '' While $decimal>0 $binary = String(Mod($decimal, 2)) & $binary $decimal = Int($decimal/2) WEnd Return $binary EndFunc Func Bin2Dec($binary) $decimal = 0 For $i = 0 To StringLen($binary) Step 1 $decimal = $decimal + Number(StringMid($binary, StringLen($binary)-$i, 1))*(2^$i) Next Return $decimal EndFunc Func Dec2Hex($decimal) $hexa = '' While $decimal>0 $single = String(Mod($decimal, 16)) If $single = '10' Then $single = 'A' If $single = '11' Then $single = 'B' If $single = '12' Then $single = 'C' If $single = '13' Then $single = 'D' If $single = '14' Then $single = 'E' If $single = '15' Then $single = 'F' $hexa = $single & $hexa $decimal = Int($decimal/16) WEnd Return $hexa EndFunc Func Hex2Dec($hexa) $decimal = 0 For $i = 0 To StringLen($hexa) Step 1 $char = StringMid($hexa, StringLen($hexa)-$i, 1) If $char='A' Then $single = 10 ElseIf $char='B' Then $single = 11 ElseIf $char='C' Then $single = 12 ElseIf $char='D' Then $single = 13 ElseIf $char='E' Then $single = 14 ElseIf $char='F' Then $single = 15 Else $single = Number($char) EndIf $decimal = $decimal + $single*(16^$i) Next Return $decimal EndFunc Func Bin2Hex($binary) Return Dec2Hex(Bin2Dec($binary)) EndFunc Func Hex2Bin($hexa) Return Dec2Bin(Hex2Dec($hexa)) EndFunc Greetings, ZeD Link to comment Share on other sites More sharing options...
Valik Posted September 16, 2004 Share Posted September 16, 2004 If you search the forum, you should find several base 2 - 36 converters several of us wrote using different strategies... Link to comment Share on other sites More sharing options...
ZeDMIN Posted September 16, 2004 Author Share Posted September 16, 2004 DOH!!! I'm sorry. I DID search the forum but it seems like i used wrong keywords. I will never post any functions again, i promise Greetings, ZeD Link to comment Share on other sites More sharing options...
Lazycat Posted September 16, 2004 Share Posted September 16, 2004 I will never post any functions again, i promise Nevermind! I think it's just interesting to compare different ways to make the same things Different methods may vary by speed, range of use etc. For example, how many sorting methods we have?.. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Beastmaster Posted September 16, 2004 Share Posted September 16, 2004 @KotAs I have been advised to rethink about my Avatar I think it's fair enough to let you know that your nick could be a challenge if used in Austria/Germany and parts of Switzerland - means in an environment where people are used, or able to speak German .Click this --> [Kot] Link to comment Share on other sites More sharing options...
Lazycat Posted September 17, 2004 Share Posted September 17, 2004 Mmm... I always know before that this was mistake... but I don't know HOW This is like confusion with the "Matroska" container name. I would like to change this to more neitral but this is not so easy as changing avatar... or? Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
this-is-me Posted September 17, 2004 Share Posted September 17, 2004 There is a good point. I think you would have to ask an administrator of the board like jon or larry to transfer your account in the backend to allow you to keep your status and information. Who else would I be? Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 19, 2004 Administrators Share Posted September 19, 2004 @Kot As I have been advised to rethink about my Avatar I think it's fair enough to let you know that your nick could be a challenge if used in Austria/Germany and parts of Switzerland - means in an environment where people are used, or able to speak German . Click this --> [Kot] Someone asked you to change avatar? What just because it's aguy with horns/devil thing? Does that mean I can't use this emoticon anymore ? Tut. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Somerset Posted September 19, 2004 Share Posted September 19, 2004 Jon i know someone asked beastmaster if his avitar was demonic. i dunno about you, but what others think about a name or picture is just subjective. Beastmaster shouldn't take offense to any of it... anyone that uses internet explorer is demonic follower.... Link to comment Share on other sites More sharing options...
this-is-me Posted September 20, 2004 Share Posted September 20, 2004 Everyone has a chance to choose the right or wrong way. What choice they make is theirs to make, but I am trying to help them out. @jon, The emoticon is not the best. I am not telling you not to use it, and I didn't say that I requied anyone needed to change their avatar. I simply said that I hated to see it and that it was demonic. @beerman, No offense was intended to beastmaster. Because he has an avatar that reflects something demonic doesn't mean I want to run him off of this forum. I would simply prefer not to see it. As for your signature, I refer to John 10:1-4 Those who know God hear his voice. Those who don't know Him and still hear voices are those who have problems. Also, It is God, not god. A god is an idol. Jesus is God [capital G]. I also mean no offense to you. I have no problems with you as a person. The problems I may have are related to the things people do or say. No harm is intended towards anyone here. Who else would I be? Link to comment Share on other sites More sharing options...
Valik Posted September 20, 2004 Share Posted September 20, 2004 I would advise you very strongly to keep religion off this forum. I can promise you that you won't like what you find. If you have a problem with that avatar, block it, or if thats not an option and it bugs you bad enough, disable avatars altogether (Its a forum option). And I also don't think its very nice you asked BL@(K-R34P3R to change his signature (Provided the one in question is: -I am the giver of life and the bringer of death.). You can disable signatures as well. Link to comment Share on other sites More sharing options...
this-is-me Posted September 20, 2004 Share Posted September 20, 2004 @valik, Thank you for your information. Post edited on BL@(K-R34P3R. How do I disable signatures? Who else would I be? Link to comment Share on other sites More sharing options...
Valik Posted September 20, 2004 Share Posted September 20, 2004 My Controls->Board Settings->Board Display Settings (Top item under that) Link to comment Share on other sites More sharing options...
this-is-me Posted September 20, 2004 Share Posted September 20, 2004 Yay! no avatars, no sigs. Not even my own. LOL Who else would I be? Link to comment Share on other sites More sharing options...
ezzetabi Posted September 20, 2004 Share Posted September 20, 2004 I also usually disable those things in Forums. But in this one I found no need. Avatars have to be small, and I saw only one sig with a big pic. I saw forums with huge pictures every signature... Horrible. Link to comment Share on other sites More sharing options...
emmanuel Posted September 20, 2004 Share Posted September 20, 2004 (edited) Jesus is God [capital G]. <{POST_SNAPBACK}>And now you're offending me, much more than any userpic or emoticon ever could. But I think we should just go with Valik's suggestion and not use this place as a forum for religeous discussion. I would advise you very strongly to keep religion off this forum. I can promise you that you won't like what you find. If you have a problem with that avatar, block it, or if thats not an option and it bugs you bad enough, disable avatars altogether (Its a forum option). And I also don't think its very nice you asked BL@(K-R34P3R to change his signature (Provided the one in question is: -I am the giver of life and the bringer of death.). You can disable signatures as well. <{POST_SNAPBACK}>Edit: whoops, I hadn't read the second page, please excuse my picking up a dead string with a message of "drop it" No one's perfect, right? Edited September 20, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) 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