sizeof int [英] Sizeof int

查看:82
本文介绍了sizeof int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有没有办法改变int类型的sizeof?是否可以通过更改编译器中的某些头文件来获得
返回3或5?


提前感谢。

推荐答案



write2g ... @ gmail.com写道:

write2g...@gmail.com wrote:




有没有办法改变int类型的大小?是否可以使它成为
Hi,

Is there a way to change the sizeof int type? Is it posible to make it



没有办法,你可以通过

你的程序来改变int的大小。

好​​吧,int的大小取决于机器上单词的大小和

非常依赖于架构。

No there is no ways, by whihc you can change the size of the int from
your program.
Well, The size of int depends upon the size of word on the machine and
is very much architecture dependent.


通过更改编译器中的某些头文件返回3或5?
return 3 or 5 by changing some header file in the compiler?



雅你可以通过更改或编写自己的自定义

编译器来确定这样做,但是你会在哪台机器上执行该程序,

编译器取决于底层机器,这样做会使得b $ b没有任何意义。

Ya you can surely do that by making changes or writing your own custom
compiler but on what machine would you execute the program,
The compiler is depending on the underlying machine, and doing so would
not make any sense.


谢谢提前。
Thanks in advance.



干杯,

SandeepKsinha。

Cheers,
SandeepKsinha.


wr********@gmail.com 写道:




有没有办法改变int类型的大小?是否可以通过更改编译器中的某些头文件来使它变为
返回3或5?
Hi,

Is there a way to change the sizeof int type? Is it posible to make it
return 3 or 5 by changing some header file in the compiler?



假设你可以,为什么会这样?


Tom

Supposing you could, why would you?

Tom


Tom St Denis写道:
Tom St Denis wrote:
wr **** **** @gmail.com 写道:
wr********@gmail.com wrote:

>>

有没有办法改变sizeof int类型?是否可以通过更改编译器中的某些头文件使其返回3或5?
>>Hi,

Is there a way to change the sizeof int type? Is it posible to make it
return 3 or 5 by changing some header file in the compiler?




假设你可以,为什么?



Supposing you could, why would you?



/ *此模块中的高精度计算

*需要一个1000位有符号整数,所以...

* /

#include< limits.h>

sizeof(int)=(1000 + CHAR_BIT - 1)/ CHAR_BIT;

/ *

*难道科学不错吗?

* /


它不起作用但是这样:sizeof只描述了实现提供的数据类型,但没有控制它们的特性。与CHAR_BIT和

类似:你不能得到脂肪整数。通过重新定义

INT_MAX到一个比平常更大的数字。


< off-topic>


我编程的第一台电脑实际上具有这个能力的
!整数通常为五位小数

宽,值介于-99999和+99999之间,但在选项卡的下降

时,你可以使它们更宽,更精确

或更窄以获得更好的存储经济性。我很确定你

不能让它们比两位数(-99到+99)窄,但是

我再也记不起上面的了限制是。如果

是一个上限,那么它是由编译器强加的,而b / b不是由底层硬件强加的:机器本身非常好

很高兴使用与五位数值相同的

指令来处理千位整数。


那是在1960年代中期在IBM 1620上使用FORTRAN II。

这表明我们已经提升了多远,我们不再拥有这种灵活性,而是制造了这种灵活性在一些机器设计师选择对我们造成的任何事情中,我只能躺在任何地方.-)


< / off-topic>


-

Eric Sosman
es **** *@acm-dot-org.inva 盖子


这篇关于sizeof int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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