I tried to get the MAX value for int using tilde. But the conclusion is not what I expected. When I ran this:
#include <stdio.h>
#include <limits.h>
int main(){
int a=0;
a=~a;
printf("\nMax value: %d",-a);
printf("\nMax value: %d",INT_MAX);
return 0;
}
I get the output:
Maximum value: 1
Maximum Value: 2147483647
I thought (for example) if I have 0000 in RAM (I know that the first bit shows the number pozitiv or negativ). After ~ 0000 => 1111 and after - ( 1111 ) => 0111 , that I would get a MAX value.
source
share