C ++ is longoften a 32-bit data type. It looks like your system does not have enough bits to represent 3633091313, so the result is negative. This behavior is undefined in C ++ ( corresponding to Q & A ).
In C #, which corresponds to converting to int:
UInt64 ul = 3633091313UL;
Int32 l = (int)ul;
Console.WriteLine(l);
Demo version
source
share