私のコードの数学と変換プロセスに頭を悩ませています。私はそれがどのようにその合計に達したのか理解していますが、どのようにマイナスになったのですかバイトからintへの変換の計算
static void Main(string[] args)
{
short numb1 = 30000, numb2 = 30000;
short answer = (short)Add(numb1, numb2);
Console.WriteLine("{0} + {1} = {2}", numb1, numb2, answer);
NarrowingAttempt();
Console.ReadLine();
}
static int Add(int x, int y)
{
return x + y;
}
static void NarrowingAttempt()
{
byte myByte = 0;
int myInt = 200;
myByte = (byte)myInt;
Console.WriteLine("Value of myByte: {0}", myByte);
}
これが返されます。
30000 + 30000 = -5536
少しの助けを?
(2 * 16)とは何ですか? – momo003
これは、65536が2の16乗(2^16,2 ** 16など)であることを意味します。 –