失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > double long unsigned int char类型数据所占字节数(C语言)

double long unsigned int char类型数据所占字节数(C语言)

时间:2021-06-13 11:49:20

相关推荐

double long unsigned int char类型数据所占字节数(C语言)

我喜欢简单粗暴一点的学习方式,怎么简单怎么来。。。。。

所以不会去去写太多没用的东西。

和机器字长及编译器有关系:

所以,int,long int,short int的宽度都可能随编译器而异。

但有几条铁定的原则(ANSI/ISO制订的):

1 sizeof(short int)<=sizeof(int)

2 sizeof(int)<=sizeof(long int)

3 short int至少应为16位(2字节)

4 long int至少应为32位。

unsigned 是无符号的意思。

一、16位编译器

char :1个字节

char*(即指针变量): 2个字节

short int : 2个字节

int: 2个字节

unsigned int : 2个字节

float: 4个字节

double: 8个字节

long: 4个字节

long long: 8个字节

unsigned long: 4个字节

二、32位编译器

char :1个字节

char*(即指针变量): 4个字节

short int : 2个字节

int: 4个字节

unsigned int : 4个字节

float: 4个字节

double: 8个字节

long: 4个字节

long long: 8个字节

unsigned long: 4个字节

三、64位编译器

char :1个字节

char*(即指针变量): 8个字节

short int : 2个字节

int: 4个字节

unsigned int : 4个字节

float: 4个字节

double: 8个字节

long: 8个字节 (定义是long至少不小于int)

long long: 8个字节 (long long至少不小于long)

unsigned long: 8个字节

C标准要求 float 类型精度7位 double双精度完全保证的有效数字最高是15位。

2^8=256

2^16=65536

2^32=4 294 967 296(40亿)

2^64=18446744073709551616 (188亿)

在做ACM题时,经常都会遇到一些比较大的整数。而常用的内置整数类型常常显得太小了:其中long 和 int 范围是[-2^31,2^31),即-2147483648~2147483647。而unsigned范围是[0,2^32),即0~4294967295。也就是说,常规的32位整数只能够处理40亿以下的数。

那遇到比40亿要大的数怎么办呢?这时就要用到C++的64位扩展了。

Dev-C++的g++编译器

scanf("%I64d",&a);

printf("%I64d",a);

VC的话

scanf("%lld",&a);

printf("%lld",a);

如果觉得《double long unsigned int char类型数据所占字节数(C语言)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。