I have a doubt from the code snippets below.
I ran this code on a 64-bit machine (x86_64-linux-gnu). I see that the value of Val overflows when the data type is unsigned integer .
#include<stdio.h> main() { unsigned int Val = 0xFFFFFFFF-15, Val2 = 0xFFFFFFFF; if (Val+16 < Val2) { printf("Val is less than Val2\n"); } }
If the data type is unsigned char , it does not overflow.
#include<stdio.h> main() { unsigned char Val = 0xFF-15, Val2 = 0xFF; if (Val+16 < Val2) { printf("Val is less than Val2\n"); } }
I have two questions:
- Does
Val increase by a high data type when the data type is unsigned char? - If so, why didnβt he get a boost from 32-bit to 64-bit
unsigned long ?
source share