Since 60000 ^ 2 is 3600000000, but the largest number that int can contain is 2 147 483 647, so it starts with -2,147,483,648.
An acceleration may contain 65,535, and then starts at 0:
For example, this prints 0:
ushort myShort = 65535; myShort++; Console.WriteLine(myShort);
Itβs easier to see this if you break it down into steps:
var B = A * A;
This actually exceeds the capacity of int32, so it starts with -2,147,483,648, so b
is -694967296 then, when you split B / A, you get: -11582, which when throws into ushort becomes 53954.
ushort A = 60000; var B = A * A;
The reason why 40,000 works is because it does not exceed int32 capacity.
ushort A = 40000; var B = A * A;
uint
can contain 60,000 ^ 2, so this works:
ushort A = 60000; var B = (uint)A * A;
The reason C casting for ushort yeilds 53954 is because C bytes are:
96 234 0 0
And bytes D:
96 234
So they contain the same support bytes, so you get 53954 and -11582