当前位置:网站首页>字长和数据类型
字长和数据类型
2022-04-22 13:39:00 【Li-Yongjun】
字长
机器一次能完成处理的数据被称为字。字是指位数,人们说某个机器是多少“位”时,其实说的就是该机的字长。比如说,当人们说奔腾是 32 位芯片时,他们的意思是奔腾的字长为 32 位,也就是 4 字节。
处理器通用寄存器的大小和它的字长是相同的。
C 语言定义的 long 类型总等于机器的字长。
数据类型
C 语言规定了变量的最小长度,但没有规定变量具体的标准长度。
不过有以下准则:
- ANSI C 标准规定,一个 char 的长度一定是 8 位。
- 尽管没有规定 int 类型的长度是 32 位,但在 linux 当前所有支持的体系结构中,它都是 32 位的。
- short 类型也类似,在当前所有支持的体系结构中,虽然没有明文规定,但它都是 16 位的。
- long 类型被确定为机器的字长,为 32 位或 64 位。
char 类型的符号问题
C 标准表示 char 类型可以带符号也可以不带符号,由具体的编译器、处理器或由它们两者共同决定到底 char 是带符号合适还是不带符号合适。
大部分体系结构上,char 默认是带符号的,它可以自 -128 到 127 之间取值。但也有一些例外,比如 ARM 体系结构上,char 就是不带符号的,它的取值范围是 0~255。
不会出错的写法:
signed char i = -1;
unsigned char i = 255;
版权声明
本文为[Li-Yongjun]所创,转载请带上原文链接,感谢
https://liyongjun.blog.csdn.net/article/details/124290804
边栏推荐
- Apache skywalking alarm Configuration Guide
- Functional limit of calculus
- 浅学一下Shell脚本(5)--函数,随机数,正则表达式
- Citrix SQL数据如何进行多表联查
- HDU 2544 Dijkstra (template)
- vscode 数据库调用存储过程,出现Unreconized data
- io_uring技术在分布式云原生数据库中的应用
- Array and string offset access syntax with curly braces is deprecated
- Harbor v2.5更新,都增加了哪些功能?
- 国元期货公司开户是否可靠?交易安全吗?
猜你喜欢

Good collection (1)

Reading target detection (2): fast r-cnn

Citrix SQL数据如何进行多表联查

自动化测试的生命周期是什么?

redis持久化

数据库资源负载管理(下篇)

Digital twin: how to support the industrial transformation of a trillion market?

Walk in the clouds - travel to the edge of the universe
BAIC Foton, Sinopec and light engineering Internet of things set up Sinopec to sell hydrogen energy (Beijing)

Model based RL概述
随机推荐
PHP 零基础入门笔记(12):数组 array
微信小程序添加数据到数据库
Fizz企业级微服务网关-服务编排,祭出终结BFF层的大杀器
分省创新能力面板数据 - 含专利数、成交额等多指标数据(2008-2019年)
Redisconfig configuration class
XML external entity attack principle and Practice (xxE) (1)
Algorithm --- reverse linked list (kotlin)
POJ 3259 最短路SPFA + 负环 (模板)
[fluent special topic] 91 illustration of future (II) yyds dry goods inventory of dart single thread asynchronous processing
Station B cuts to the live broadcast, sooner or later
Can ainai get out of the dilemma by 35 billion yuan?
html文件中通过meta信息控制缓存有效果吗?目前用的多吗?
说了栈和队列的区别以后,面试官当场就吐了,同学们千万要引以为戒。
托宾Q数据-沪深A股上市公司(含行业名称、代码等指标)2003-2020
Wong Kwong Yu Kwai tiktok is unable to sleep soundly.
Redis persistence
Network configuration in NAT mode after VMware virtual machine cloning
快速串讲校招高频面试题——排序算法和复杂度
OSPF basic configuration of routing basis
Array and string offset access syntax with curly braces is deprecated