Relive Posted August 6, 2012 Share Posted August 6, 2012 I was curious of trying to find the binaries of a decimal value so I thought of using Binary(), but it yielded a result that solved my other problem of my older project. It was painful to try and solve the problem months ago but this accidental approach really helped me out. $decimal = 69 $binary = binary($decimal) MsgBox(0, "", _ "decimal: " & $decimal & @CR & _ "binary: " & $binary & @CR & _ ;it made it reversed hex already? where's 0s and 1s? "hexadecimal v1: " & hex($binary) ) ;same as binary? ok, it removed 0x but 0x indicates a set as hex. So 69 wasn't converted to 0s and 1s but instead Binary() gave me 0x45000000, which is the reversed hex (little endian) of 0x00000045. There's nothing in the Help file that clearly explains the usage of this. Then I tried converting the result with Hex(), and ironically it yield the same result but removed the 0x. I thought 0x denotes an alphanumeric set as hexadecimal? Anyways, I wished this function was better documented so I wouldn't have to spend months just to solve something so simple. I wasn't on it for 24/7 but you get the point. Link to comment Share on other sites More sharing options...
jvanegmond Posted August 6, 2012 Share Posted August 6, 2012 How would a concatenation on a binary data type work? This is a given for programmers: There is an implicit binary to string conversion. You are looking at the string representation of the binary data type, not the binary data itself. To do that the function String is called which makes it more or less human-readable, hence the 0x. For Hex that would be inappropriate. I found something in the help file that would have helped you, but it's not in a convenient place. It describes the transformation that String does on binary data. See Remarks on BinaryToString (which could be a sensible place to look btw):Unlike String() which returns a hexidecimal representation of binary data, this function will assume the binary data is a string value and convert it appropriately.To print 1s and 0s would be meaningless. Data is data no matter the representation: Hex is more convenient for everyone. github.com/jvanegmond Link to comment Share on other sites More sharing options...
czardas Posted August 6, 2012 Share Posted August 6, 2012 To print 1s and 0s would be meaningless. Data is data no matter the representation: Hex is more convenient for everyone.I have to throw my 2p. Hex is convenient for programmers. I would say that as a counting system, hex is not top dog in the ranking order of usefulness. It is the number of prime factors that I would say have bearing on this, and decimal is slightly better than hex but less useful than dodecimal. enz....For representing binary hex is particularly convenient. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jvanegmond Posted August 6, 2012 Share Posted August 6, 2012 And with everyone I meant everyone who might have an interested in the string representation of binary data, i.e. programmers. github.com/jvanegmond Link to comment Share on other sites More sharing options...
czardas Posted August 6, 2012 Share Posted August 6, 2012 (edited) I don't know why I said dodecimal was better than decimal: Although it has more factors, it actually has the same number of prime factors, how embarrassing! I don't know! If I want to shift a bunch of ones to the left, I like to see them move. Edited August 6, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Grantson Posted September 28, 2012 Share Posted September 28, 2012 Did you ever figure this out? I'm looking for a way to convert a Hex to its corresponding binary number so that i can manipulate the bits Link to comment Share on other sites More sharing options...
czardas Posted September 28, 2012 Share Posted September 28, 2012 I'm looking for a way to convert a Hex to its corresponding binary number so that i can manipulate the bitsLook here. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Grantson Posted September 28, 2012 Share Posted September 28, 2012 Thanks Czardas & thanks to UEZ for the code spent the afternoon trying nested ifs and other loops to try and process the hex values. Not Fun Link to comment Share on other sites More sharing options...
czardas Posted September 28, 2012 Share Posted September 28, 2012 I'm sure you will conquer it. Any issues that you encounter, you should ask about it in Help and Support. operator64 ArrayWorkshop 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