计算基本数据类型的限制? [英] computing limit of basic data types ?

查看:93
本文介绍了计算基本数据类型的限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我必须开发一个程序来计算运行时所有数据类型的范围

time ...


意思是说char c;


现在我必须看看char可以代表多少个字符,


一个逻辑我想是开始递增直到循环回到0

(对于无符号)和/或-128(对于签名)....


然而,这种骑行在所有平台上都是统一的,或者不是......


还有什么方法可以做到......不使用标题定义限制

常量。 ...


帮帮我...这个..


sandSpiderX

解决方案




sandSpiderX写道:



我必须开发一个程序在运行时计算所有数据类型的范围

家庭作业,是吗?请给我们一个更好的描述。意思是说char c;

现在我必须看看char可以表示多少个字符,

我认为一个逻辑是开始递增直到循环回到0
(对于未签名)和/或-128(签名)....


问题:你怎么知道限制是-128?

sizeof(char)== 1字节== CHAR_BITS位(不一定是= 8

位)

然而,这种循环在所有平台上都是unifrom或不是......

还有什么方法可以做到......不使用标题定义的限制
常量....
帮助我......用这个..



过量的省略号并不能反映出你的思维能力。

你可以没有它们。


嗨Suman,


没有作业....只是在处理一些应用程序部分....

它就像应用程序一样将在多个平台上运行并且

将生产全系列的角色d其他数据的范围

类型....


为此我试图在运行时计算数据类型范围....


我做错了....

什么是最好的方式....


该模块将会是在Solaris,HP / AUX,Intel,Mac

等编译和运行....


sandSpiderX


Suman ::


只是忘了......它没有过量的省略号,


它的最好的方式给读者一些分手的时间和

更仔细地分析她正在阅读的内容...


sandSpiderX

Hi,

I have to develop a program to compute range of all data types at run
time...

meaning say char c;

now I have to see how many characters char can represent,,

one logic i think is to start incrementing till the loop goes back to 0
(for unsigned) and/or -128 (for signed)....

However this cycling is unifrom across all platforms or not...

What other way can this be done...without using header defined limit
constants....

Help me..with this..

sandSpiderX

解决方案



sandSpiderX wrote:

Hi,

I have to develop a program to compute range of all data types at run
time...
Homework, eh? Give us a better description, please. meaning say char c;

now I have to see how many characters char can represent,,

one logic i think is to start incrementing till the loop goes back to 0
(for unsigned) and/or -128 (for signed)....
Question: How do you know the limit is -128 or not?
sizeof(char) == 1 byte == CHAR_BITS bits (which is not necessarily = 8
bits)

However this cycling is unifrom across all platforms or not...

What other way can this be done...without using header defined limit
constants....
Help me..with this..


And an overdose of ellipsis does not reflect your thinking prowess.
You could have done without them.


Hi Suman,

No homework....just working on some application part....
Its like the application is going to run on mutiple platforms and is
going to produce full range of charactersets and range for other data
types....

for this I am trying to compute data type range at runtime....

Am I doing wrong ....
Whats the best way....

The module is going to be compiled and run on Solaris,HP/AUX,Intel, Mac
and the like....

sandSpiderX


Suman ::

Just forgot...its not overdose of ellipsis,

Its the best way to give the reader some time for breaking up and
analysing more carefully what she is reading...

sandSpiderX


这篇关于计算基本数据类型的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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