64位 - 在C的int值和长32范围 [英] Range of values in C Int and Long 32 - 64 bits

查看:168
本文介绍了64位 - 在C的int值和长32范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑与C范围内int变量的值。

我知道,一个32位无符号整型的范围是:0〜65535。
只要有0〜4294967295

这是在32位机的罚款。但是,现在在64位机器上的所有事情保持相同的?
或者,也许我INT能力是不同的?

我明白这个问题,作为新手,但我真的很困惑。
该方法的签名是没有帮助过。 :)

 无符号长long int类型atomicAdd(无符号长长整型*地址,无符号长长整型VAL);


解决方案

在C和C ++你有这些要求的最少(即实际的实现可以有更大的幅度)

 符号字符:-2 ^ 07 + 1 + 2 ^ 07-1
总之:-2 ^ 15 + 1 + 2 ^ 15-1
INT:-2 ^ 15 + 1 + 2 ^ 15-1
长:-2 ^ 31 + 1 + 2 ^ 31-1
很长很长:-2 ^ 63 + 1 + 2 ^ 63-1

现在,在特定的实现,您有多种位范围。该维基百科的文章介绍这很好。

I'm confused with range of values of Int variable in C.

I know that a 32bits unsigned int have a range of: 0 to 65,535. So long has 0 to 4,294,967,295

This is fine in 32bits machine. But now in 64bits machines all thing keep the same? Or maybe my int capacity is different?

I understand this questions as newbie, but I'm really confused. This method signature is not helping too. :)

unsigned long long int atomicAdd(unsigned long long int* address, unsigned long long int val);

解决方案

In C and C++ you have these least requirements (i.e actual implementations can have larger magnitudes)

signed char: -2^07+1 to +2^07-1
short:       -2^15+1 to +2^15-1
int:         -2^15+1 to +2^15-1
long:        -2^31+1 to +2^31-1
long long:   -2^63+1 to +2^63-1

Now, on particular implementations, you have a variety of bit ranges. The wikipedia article describes this nicely.

这篇关于64位 - 在C的int值和长32范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆