I am trying to convert a negative number to binary form in 8 bits.
here is my code :-
UTF8Encoding Bencoding = new UTF8Encoding();
int a=-3;
byte[] Bbuf = Bencoding.GetBytes(a.ToString());
StringBuilder Binfobinary = new StringBuilder();
foreach (byte b in Bbuf)
{
string str = Convert.ToString(b, 2);
Binfobinary.Append(str);
}
it gives me answer like this
101101110011
1 Answer