Objective-C基本数据类型取值范围、字节

类型限定修饰词

一些类型限定修饰词

  • short短型,修饰int、double;
  • long长型,修饰int、double;
  • signed有符号型,修饰int、char;
  • unsigned 无符号型,修饰int、char;

1.这些限定词经常用来限定int型,在限定int类型时int可以省略;
2.short和long会改变int型的长度,在不同编译器长度不相同,但是一般short长度不大于int,int长度不大于long;
3.signed和unsigned不会改变类型长度,仅表示最高位是否为符号位,其中unsigned表示大于等于0的正数;

取值范围

为了以后开发中能够方便查找,并正确的使用数据类型,下面是部分数据类型的取值范围:

  • int:-2147483648~2147483647
  • unsigned int:0~4294967295
  • short:-32768~32767
  • unsigned short:0~65535
  • long: -2147483648~2147483647
  • unsigned long:0~4294967295

存储空间

下面列出的是常用数据类型占用的存储空间

数据类型16位编译器32位编译器64位编译器
char1byte1byte1byte
int2byte4byte4byte
float4byte4byte4byte
double8byte8byte8byte
short int2byte2byte2byte
unsigned int2byte4byte4byte
long4byte4byte8byte
unsigned long4byte4byte8byte
long long8byte8byte8byte

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值