As you noticed, the Int32
range is -2147,483,648 to 2,147,483,647, so any number within this range can be stored, but ONLY digits in this range can be used. 4,294,901,760 is larger than 2,147,483,647, therefore it does not fit into Int32
.
What to do, it depends on what you want to achieve. If you want just Int32
with the ffff0000
, then as suggested using unchecked
:
int y = unchecked((int)0xffff0000);
y
now has a value of -65536, which is a bit pattern interpreted as a signed integer.
But! If you really need a value of UInt32
, you should use a suitable data type - like UInt32
.
Aakashm
source share