The following code:
private const uint FIRMWARE_DOWNLOAD_ADDRESS = 0x00001800;
public void someFunc(){
byte[] command = new byte[16];
command[11] = (byte)(FIRMWARE_DOWNLOAD_ADDRESS >> 24);
command[10] = (byte)(FIRMWARE_DOWNLOAD_ADDRESS >> 16);
command[9] = (byte)(FIRMWARE_DOWNLOAD_ADDRESS >> 8);
command[8] = (byte)(FIRMWARE_DOWNLOAD_ADDRESS); //error: Overflow in constant value computation
}
throws an error Overflow in constant value computation.
Why? From what I understand 0x00001800 <= 0xffffffff so there should be no overflow happening.
And why don't the other 3 lines throw an error? I tried to do:
command[8] = (byte)(FIRMWARE_DOWNLOAD_ADDRESS >>0);
thinking that the right shift operator was somehow checking for the overflow condition but this still gives the same error.