STM32F10X.H

 #include "core_cm3.h"
#include "system_stm32f10x.h"
#include <stdint.h> /** @addtogroup Exported_types
* @{
*/ /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */
typedef int32_t s32;
typedef int16_t s16;
typedef int8_t s8; typedef const int32_t sc32; /*!< Read Only */
typedef const int16_t sc16; /*!< Read Only */
typedef const int8_t sc8; /*!< Read Only */ typedef __IO int32_t vs32;
typedef __IO int16_t vs16;
typedef __IO int8_t vs8; typedef __I int32_t vsc32; /*!< Read Only */
typedef __I int16_t vsc16; /*!< Read Only */
typedef __I int8_t vsc8; /*!< Read Only */ typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8; typedef const uint32_t uc32; /*!< Read Only */
typedef const uint16_t uc16; /*!< Read Only */
typedef const uint8_t uc8; /*!< Read Only */ typedef __IO uint32_t vu32;
typedef __IO uint16_t vu16;
typedef __IO uint8_t vu8; typedef __I uint32_t vuc32; /*!< Read Only */
typedef __I uint16_t vuc16; /*!< Read Only */
typedef __I uint8_t vuc8; /*!< Read Only */ typedef enum {RESET = , SET = !RESET} FlagStatus, ITStatus; typedef enum {DISABLE = , ENABLE = !DISABLE} FunctionalState;
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum {ERROR = , SUCCESS = !ERROR} ErrorStatus;

源定义在#include<stdint.h>中

 /*
* 'signed' is redundant below, except for 'signed char' and if
* the typedef is used to declare a bitfield.
*/ /* 7.18.1.1 */ /* 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; /* 7.18.1.2 */ /* smallest type of at least n bits */
/* minimum-width signed integer types */
typedef signed char int_least8_t;
typedef signed short int int_least16_t;
typedef signed int int_least32_t;
typedef signed __INT64 int_least64_t; /* minimum-width unsigned integer types */
typedef unsigned char uint_least8_t;
typedef unsigned short int uint_least16_t;
typedef unsigned int uint_least32_t;
typedef unsigned __INT64 uint_least64_t; /* 7.18.1.3 */ /* fastest minimum-width signed integer types */
typedef signed int int_fast8_t;
typedef signed int int_fast16_t;
typedef signed int int_fast32_t;
typedef signed __INT64 int_fast64_t; /* fastest minimum-width unsigned integer types */
typedef unsigned int uint_fast8_t;
typedef unsigned int uint_fast16_t;
typedef unsigned int uint_fast32_t;
typedef unsigned __INT64 uint_fast64_t; /* 7.18.1.4 integer types capable of holding object pointers */
#if __sizeof_ptr == 8
typedef signed __INT64 intptr_t;
typedef unsigned __INT64 uintptr_t;
#else
typedef signed int intptr_t;
typedef unsigned int uintptr_t;
#endif /* 7.18.1.5 greatest-width integer types */
typedef signed __LONGLONG intmax_t;
typedef unsigned __LONGLONG uintmax_t;

由上述可知:

1、有符号整型

  • s8 占用1个byte,数据范围 -2^7  到 (2^7-1)
  • s16 占用2个byte,数据范围 -2^15 到 (2^15-1)
  • s32 占用 4个byte,数据范围 -2^31 到 (2^31-1)2^31  = 2147483647
  • int64_t占用8个byte,数据范围 -2^63 到 (2^63-1)    2^63 = 9223372036854775807ll

2、无符号整型

  • u8  占用1个byte, 数据范围 0 - 2^8
  • u16 占用2个byte, 数据范围 0 - 2^16
  • u32 占用4个byte, 数据范围 0 - 2^32 2^32  = 4294967295
  • uint64_t 占用8个byte, 数据范围 0 - 2^64 2^64  = 18446744073709551615
3、浮点型
  • float ——4个byte,有符号型,可以表达负数/小数; Float 类型至少要能精确表示到小数点后6位。
  • double——8个byte,有符号型,可以表达负数/小数;Double 类型至少要能精确到小数点后 10 位。

二、不同数据类型混合运算

在C语言中,不同类型的数据间是可以混合运算的。在进行运算时,不同类型的数据要先转换成同一类型,然后进行运算。转换的规则如下:

注意:箭头的方向只表示数据类型级别的高低,由低向高转换,这个转换过程是一步到位的。

(三)数据类型转换规则

各类数据类型的转换,分为两种方式:隐式(编译软件自动完成),显式(程序强制转换)

隐式转换规则:

字符必须先转换为整数(C语言规定字符类型数据和整型数据之间可以通用) 
   short型转换为int型(同属于整型) 
   float型数据在运算时一律转换为双精度(double)型,以提高运算精度(同属于实型) 
   赋值时,一律是右部值转换为左部类型 
[注] 
     当整型数据和双精度数据进行运算时,C先将整型数据转换成双精度型数据,再进行运算,结果为双精度类型数据 
     当字符型数据和实型数据进行运算时,C先将字符型数据转换成实型数据,然后进行计算,结果为实型数据

显式转换规则:

例:(int)(x+y);

注:强制类型转换时,得到一个所需要的中间变量,原来变量的类型未发生变化。

最新文章

  1. 爱上MVC~图表的使用Chart
  2. Xdebug 配置
  3. 数论 - 高精度Fibonacci数 --- UVa 10183 : How Many Fibs ?
  4. 内存调试工具Electric Fence
  5. Collecting Bugs(POJ 2096)
  6. HashCode equals
  7. Java 中带参带返回值方法的使用
  8. Cisco模拟器使用和静态路由配置
  9. 关于怎样拆毁Cuttheprice
  10. java中字符串的比较
  11. Delphi利用Webbrowser登陆QQ群文档
  12. js判断手机的类型
  13. Jass 技能模型定义(转)
  14. Git学习之路(1)-Git简介
  15. Centos7——NFS(Network File System)服务
  16. python常用函数及模块
  17. plsql developer如何查询SQL语句执行历史记录(转)
  18. List和json数组的转换(赋源代码)
  19. SDOI2017 Round1 起点
  20. MRC 和 ARC 混编

热门文章

  1. Problem E: 十六进制转十进制
  2. 【MySQL笔记】解除输入的安全模式,Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.
  3. ES6的异步操作
  4. stream_get_meta_data(打开的文件句柄) 拿到任何网站服务器名字,从封装协议文件指针中取得报头/元数据
  5. 星际争霸 虚空之遗 人族5BB 操作流程
  6. PHP 5.3.13 memcache win 64 配置和安装
  7. 手动清除或刷新Linux的Swap分区
  8. postgres--wal
  9. iOS:使用block进行类与类,控制器与控制器之间的传值
  10. form表单提交时选择性传值到后台