what is the difference between uint16_t and unsigned short int incase of 64 bit processor?

前端 未结 2 1557
半阙折子戏
半阙折子戏 2021-01-31 16:17

I came to use a variable of type uint16_t, but am unable to use that data type because of my project limitations. Is it possible to unsigned short int

2条回答
  •  执笔经年
    2021-01-31 16:59

    uint16_t is guaranteed to be a unsigned integer that is 16 bits large

    unsigned short int is guaranteed to be a unsigned short integer, where short integer is defined by the compiler (and potentially compiler flags) you are currently using. For most compilers for x86 hardware a short integer is 16 bits large.

    Also note that per the ANSI C standard only the minimum size of 16 bits is defined, the maximum size is up to the developer of the compiler

    Minimum Type Limits

    Any compiler conforming to the Standard must also respect the following limits with respect to the range of values any particular type may accept. Note that these are lower limits: an implementation is free to exceed any or all of these. Note also that the minimum range for a char is dependent on whether or not a char is considered to be signed or unsigned.

    Type Minimum Range

    signed char     -127 to +127
    unsigned char      0 to 255
    short int     -32767 to +32767
    unsigned short int 0 to 65535
    

提交回复
热议问题