using System;
namespace test_warmup
{
class Program
{
static void Main(string[] args)
{
int test = -1110835200;
test = test * 1700397056;
Console.WriteLine(test);
}
}
}
Asked
Active
Viewed 82 times
-4

Camilo Terevinto
- 31,141
- 6
- 88
- 120

Jeremy T
- 1
- 1
1 Answers
2
-1110835200 * 1700397056 = -1888860903781171200
Displayed in hex, that's -0x1a3694fc_00000000
In C#, int
is only 32-bits, so the result is truncated to just 0
.
In other words, the result of that multiplication is too large to fit in the variable to which you're assigning it, and the part that fits is all zero.

Jonathon Reinhart
- 132,704
- 33
- 254
- 328
-
You can demonstrate this difference by simply changing the type to a long. `long test = -1110835200;` – ForeverZer0 Jun 24 '18 at 22:55