Compute signed long max value in C using bit shift
问题 Just started learning C yesterday and this is about to drive me crazy on the new year's day... Try to print the different int ranges using bit shift operations. Everything works fine apart from the signed long max/min value. Can't figure out why (1 << 63) - 1 returns -1 ? But (1 << 64) -1 for unsigned long long works fine... #include <limits.h> #include <stdio.h> void print_range() { signed char scmax = (1 << 7) - 1; char c = scmax; // char means signed char! unsigned char uscmax = (1 << 8) -