INT to Binary
-
Does anybody know of a way to convert an INT to it binary representation? i.e. 85 = 1010101 56 = 0111000 and so on post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42
Try checking out the System.Collections.BitArray class; it provides a pretty decent way of looking at/manipulating integers at the bit-level. I've used it a few times for win32 and mp3 stuff. Also, if you only want to check the presence/abscence of a particular bit, use the '&' bitwise operator. I've found it's extremely worthwhile to truly understand the bit-level operators, especially if you're doing those type of operations frequently.
-
Does anybody know of a way to convert an INT to it binary representation? i.e. 85 = 1010101 56 = 0111000 and so on post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42
int intSomeNumber = 999;
string strBits = Convert.ToString( intSomeNumber, 2 );Michael Flanakin Web Log