English 中文(简体)
in之间有何区别? [复制]
原标题:What is the difference between int and long? [duplicate]
  • 时间:2011-09-12 19:40:50
  •  标签:
  • c++
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
What is the difference between an int and a long in C++?
difference in long vs int data types in C++

c++是中长期数据类型之间的偏差。 改写以下法典:

int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"Int_Max = "<<INT_MAX<<endl;
    cout<<"Int_Min = "<<INT_MIN<<endl;
    cout<<"Long_Max = "<<LONG_MAX<<endl;
    cout<<"Long_Min = "<<LONG_MIN<<endl;
}

结果是......

Int_Max = 2147483647
Int_Min = -2147483648
Long_Max = 2147483647
Long_Min = -2147483648

我很混淆。

最佳回答

根据该标准,<代码>int保证至少为16个比值,long至少为32个比值。 在大多数32位汇编者中,两者都是相同的,均为32个。 但是,由于还有64、16、甚至8个实体的汇编者,你就没有这样做了。

问题回答

在32个轨道系统中,<代码>int和long之间通常没有任何区别。 如果你想要在32个轨道系统上采用64个轨道数据类型,则尝试 长期

如果你想要保证数据类型的规模,你就应当使用星体中的类型(需要C++0x支持g++,通过汇编-std=c++0x 而得到这种支持)。 例如,你将使用t32_t and int64_t,而不是 in或长。 如果你想要一个没有签名的数据类型,就只会增加一个起点。 页: 1 这是一种16倍的未签名的分类账。

然而,你只应当利用这些空间。 否则,“int”一般更为可取。

更完整的参考资料见。 除其他外,还包括诸如t_least16_t等数据类型,其范围至少为16比特。

果园:至少8个轨道:等于一个单位

简言之:至少16条轨道:至少宽度

注:至少有16个轨道:至少范围很广

long : at least 32 bits : at least as wide as int





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签