在编程过程中,不同的 CPU,其数据类型的意义各不相同,所以一定要注意相
应变量数据类型的定义和转换,否则在计算中可能会出现不确定的错误。
(一)C 语言中的种类数据
整型:int short long
实型:oat double
STM32 中的数据类型非常的多,常用的变量,文件中的定义如下:
/* exact-width signed integer types */
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed __int64 int64_t;
/* exact-width unsigned integer types */
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
还有 oat int 编译器中不能看到其定义(估计已编译了)。
因此在 STM32 编程中,常用的数据类型有:char(字符型),u8,u16
,u32,但是在一些计算中,涉及到负数,小数,因此要用到:int oat
doulbe 型。
其中 u8——1 个字节,无符号型(不能表达负数,如果用来当作负数的话,就
出错了);
u16 ——2 个字节,无符号型(参看前边 STM32f10x.h 中的定义);
u32——4 个字节,无符号型;
评论0
最新资源