range on int, short and other data types in C on my processor?

送分小仙女□ 提交于 2019-12-06 04:08:49

From this, take a look at the footnote:

  • the actual value depends on the particular system and library implementation, but shall reflect the limits of these types in the target platform.

If you run the following code on your system, it should shed some insight because the value returned may or may not differ from the ones in the above link.

    #include <stdio.h>
    #include <float.h>
    #include <limits.h>

    int main() {
        printf("\t\tUsing <limits.h> library definitions...\n");
        printf("CHAR\n");
        printf("signed char max: %d\n", SCHAR_MAX);
        printf("unsigned char max: %u\n", UCHAR_MAX); // Note use of u, formatting output
        printf("signed char min: %d\n", SCHAR_MIN);
        printf("SHORT\n");
        printf("signed short min: %d\n", SHRT_MIN);
        printf("signed short max: %d\n", SHRT_MAX);
        printf("unsigned short max: %d\n", USHRT_MAX);
        printf("INT\n");
        printf("signed int max: %d\n", INT_MAX);
        printf("unsigned int max: %u\n", UINT_MAX); 
        printf("signed int min: %d\n", INT_MIN);
        printf("LONG\n");
        printf("signed long max: %d\n", LONG_MAX);
        printf("unsigned long max: %u\n", ULONG_MAX);
        printf("signed long min: %d\n", LONG_MIN);
        printf("FLOAT\n");
        printf("signed float max: %e\n", FLT_MAX);
        printf("signed float min: %e\n", FLT_MIN);
        printf("DOUBLE\n");
        printf("signed double max: %e\n", DBL_MAX);
        printf("signed double min: %e\n", DBL_MIN);
        return 0;
}

I hope I understood your qestion correctly.

You can take a look at limits.h, where you can find the sizes of integral types. Take a look here.

This header defines constants with the limits of fundamental integral types for the specific system and compiler implementation used.

Header <limits.h> provides these informations while <stdint.h> allows you to specify specific width integers:

INT_MAX
INT_MIN
int32_t value; // to have an integer of exactly 32 bits
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!