当前位置:网站首页>C陷阱与缺陷 第7章 可移植性缺陷 7.3 整数的大小
C陷阱与缺陷 第7章 可移植性缺陷 7.3 整数的大小
2022-07-30 17:10:00 【weixin_客子光阴】
整数的大小
C语言为编程人员提供了3种不同长度的整数:short型、int型和long型。
1、这3中类型的整数的长度是非递减的。
2、一个普通(int类型)整数足以容纳任何数组下标。
3、字符长度有硬件特性决定。
ANSI C标准要求long型整数的长度至少应该是32位,而short型和int型整数的长度至少应该是16位。
最重要的一点就是在这方面我们不能指望有任何可用的精度。
要定义这样一个变量,可移植性最好的办法就是声明该变量为long型,但在这种情况下我们定义一个“新的”类型无疑更为清晰:
typedef long tenmil;
而且,程序员可以用这个新类型来声明所有此类对象,最坏的情形也不过是我们只需要改动类型定义,所有这些变量的类型就自动变为正确的呢。
边栏推荐
- Valid bracketed strings [greedy exercise]
- 实现web实时消息推送的7种方案
- 报错500,“message“: “nested exception is org.apache.ibatis.binding.BindingException: 解决记录
- Lotus explodes the block failed
- LeetCode318:单词长度的最大乘积
- SLIM: Sparse Linear Methods (TopN推荐)
- 第六章:决胜秋招
- 哎,这要人老命的缓存一致问题啊
- You are a first-class loser, you become a first-class winner
- torch.optim.Adam() 函数用法
猜你喜欢

新零售saas小程序如何探索数字化门店的破局之路?
![[MRCTF2020]Ezaudit](/img/80/d4656abdff20703591ffdc3f5a5ebc.png)
[MRCTF2020]Ezaudit

Weka 3.8.6安装与Weka 3.8.6功能介绍

代码越写越乱?那是因为你没用责任链

升级Win11后不喜欢怎么退回Win10系统?

Research on intelligent charging strategy of matlab simulink lithium-ion battery

Tensorflow中实现正则化
![[MRCTF2020]Ezaudit](/img/80/d4656abdff20703591ffdc3f5a5ebc.png)
[MRCTF2020]Ezaudit

Shell implementation based on stm32

The first time I used debug query and found that this was empty, does it mean that the database has not been obtained yet?please help.
随机推荐
huato hot update environment construction (DLL method hot update C# code)
[HarekazeCTF2019] Avatar Uploader 1
Discuz杂志/新闻报道模板(jeavi_line)UTF8-GBK模板
有没有并发系统设计的经验,我该怎么说?
Error occurred while trying to proxy request The project suddenly can't get up
牛客网刷题——运算符问题
基于stm32的shell实现
olap——入门ClickHouse
Security business revenue growth rate exceeds 70% 360 builds digital security leader
fast shell porting
The first time I used debug query and found that this was empty, does it mean that the database has not been obtained yet?please help.
真正懂经营管理的CIO具备哪些特质
mysql进制安装与mysql密码破解
疫情之下的裁员浪潮,7点建议帮你斩获心仪offer
Chapter 5 Advanced SQL Processing
MySQL超详细安装教程 手把手教你安装MySQL到使用MySQL 最简单的MySQL安装方式,这种方式装,卸载也简单
matlab simulink锂离子电池智能充电策略研究
Oracle动态监听与静态监听详解
【AAAI2020】阿里DMR:融合Matching思想的深度排序模型
leetcode:1488. 避免洪水泛滥【二分 + 贪心】