int和long之间的区别 [英] difference between int and long
问题描述
你好所有
我对int和long数据类型感到困惑。
我读了一些书,int cal hold 2 ^ 16值
其中long可以容纳2 ^ 32。两种数据类型都是4个字节长。
我怀疑这个,因为它们都是4个字节,它怎么能保持不同的大小?
谢谢
hello all
I am bit confused with int and long data type.
I read in some book that, int cal hold 2^16 values
where in long can hold 2^32. and both data types are 4 bytes long.
My doubt this, since both are 4 bytes , how can it hold different size?
Thank you
推荐答案
Imran写道:
Imran wrote:
hello all
我对int和long数据类型感到困惑。
我在一些书中读到,int cal hold 2 ^ 16 values
长在哪里可以容纳2 ^ 32。两种数据类型都是4个字节长。
我怀疑这个,因为它们都是4个字节,它怎么能保持不同的大小?
谢谢
hello all
I am bit confused with int and long data type.
I read in some book that, int cal hold 2^16 values
where in long can hold 2^32. and both data types are 4 bytes long.
My doubt this, since both are 4 bytes , how can it hold different size?
Thank you
如果它们都是4个字节,那么它们都可以容纳2 ^ 32。 int和long之间的差异
取决于处理器的类型。在今天很多
处理器上它们完全一样。
-
Scott McPhillips [VC ++ MVP]
If they are both 4 bytes then they can both hold 2^32. The difference
between int and long depends on the type of processor. On many
processors today they are exactly the same.
--
Scott McPhillips [VC++ MVP]
Imran napsal:
Imran napsal:
hello all
我对int和long数据类型感到困惑。
我在一些书中读到,int cal hold 2 ^ 16 values
长在哪里可以容纳2 ^ 32。两种数据类型都是4个字节长。
我怀疑这个,因为它们都是4个字节,它怎么能保持不同的大小?
谢谢
hello all
I am bit confused with int and long data type.
I read in some book that, int cal hold 2^16 values
where in long can hold 2^32. and both data types are 4 bytes long.
My doubt this, since both are 4 bytes , how can it hold different size?
Thank you
标准保证只有int至少为16位且long为
至少32位且sizeof(int) < = sizeof(long)。
因此,例如在典型的32位平台上,int和long都是32位,
在64位Linux可以是32位和64位长等。
Standard guarantees only that int is at least 16-bit and long is at
least 32-bit and sizeof(int) <= sizeof(long).
So for example on typical 32-bit platform are int and long both 32-bit,
on 64-bit Linux can be int 32-bit and long 64-bit etc.
2007年1月16日星期二10:30:40 -0500,Scott McPhillips [ MVP]写道:
On Tue, 16 Jan 2007 10:30:40 -0500, Scott McPhillips [MVP] wrote:
Imran写道:
Imran wrote:
> hello all
>我对int和long数据类型感到困惑。
我在一些书中读到,int cal hold 2 ^ 16值
其中long可以容纳2 ^ 32。两种数据类型都是4个字节长。
我怀疑这个,因为它们都是4个字节,它怎么能保持不同的大小?
谢谢
>hello all
I am bit confused with int and long data type.
I read in some book that, int cal hold 2^16 values
where in long can hold 2^32. and both data types are 4 bytes long.
My doubt this, since both are 4 bytes , how can it hold different size?
Thank you
如果它们都是4个字节,那么它们都可以容纳2 ^ 32。 int和long之间的差异
取决于处理器的类型。在今天许多
处理器上它们完全相同。
If they are both 4 bytes then they can both hold 2^32. The difference
between int and long depends on the type of processor. On many
processors today they are exactly the same.
这不是真的。 C ++根据字符大小定义一个字节
必须至少为8位。
4字节的含义。因此,它的大小是char的4倍,而b
的大小必须等于32位。
That is not true. C++ defines a byte in terms of the size of a character
which must be at least 8 bits.
The meaning of "4 bytes" thus is 4 times the size of char which doesn''t
have to equal 32 bits in size.
这篇关于int和long之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!