public static void PrintHexString(byte data)
{
Console.WriteLine("Hex of {0} is {1}", data, BitConverter.ToString(BitConverter.GetBytes(data)));
}
-----------------------
private static void DemoNegativeNumberStorageInBinary()
{
Console.WriteLine("Binary Representation of {0} - {1}", 1000, Convert.ToString(1000, 2));
/* how negative is done
* short value = -7;
* 7 = 0000 0000 0000 0111
* Not (7) = 1111 1111 1111 1000
* Add 1 = 1111 1111 1111 1000
* +
* 1
* 1111 1111 1111 1001
* (1)111 1111 1111 1001 - is negative because it is 1
*
* -7 + 7 = 0
* 1111 1111 1111 1001 (+)
* 0000 0000 0000 0111
* 0000 0000 0000 0000
*/
Console.WriteLine("Binary Representation of {0} - {1}", -1000, Convert.ToString(-1000, 2));
}
-----------------------
No comments:
Post a Comment