Casting from int to uint and back
Is casting a negative int to a uint and then back to a int guaranteed to give back the original negative value on all platforms, architectures and runtimes? Thanks!
unchecked context (the default) it's just a reinterpret castunchecked-17
4294967279
-17(uint)-17- Constant value '-17' cannot be converted to a 'uint' (use 'unchecked' syntax to override)int i = -17;
uint u = (uint)i;
int i2 = (int)u;
Console.WriteLine(i);
Console.WriteLine(u);
Console.WriteLine(i2);