-
按标准来说 ,最难辨别的几个大小类型应该如下大小:
long >= int >= short -
按自身理解(仅仅个人意见),long和short真实应该是long int和short int ,从而区分为32位还是16位。
但int应该是需要根据不同的编译器来区分的,如在16位编译时,就是16位长度。 -
按在有些公司的建议,有些程序不会建议使用int(因为对于不同MCU可能会导致不同的长度,从而使移植和复用变得麻烦),而是使用long和short,这样可以更好的使模块进行移植和使用。
-
从网上总结的部分数据类型大小,只写了位的大小,请注意有符号和无符号的取值范围。
Type | Size |
---|---|
char | 8bit |
short | 16bit |
long | 32bit |
float | 32bit |
double | 64bit |
/*Type definition of standard type BOOL*/
typedef unsigned char BOOL;
/*Type definition of standard type U8*/
typedef unsigned char U8;
/*Type definition of standard type U16*/
typedef unsigned short U16;
/*Type definition of standard type U32*/
typedef unsigned long U32;
/*Type definition of standard type U64*/
typedef unsigned long long U64;
/*Type definition of standard type S8*/
typedef signed char S8;
/*Type definition of standard type S16*/
typedef signed short S16;
/*Type definition of standard type S32*/
typedef signed long S32;
/*Type definition of standard type S64*/
typedef signed long long S64;
/*Type definition of standard type F32*/
typedef float F32;
/*Type definition of standard type F64*/
typedef double F64;