在unix中采用unsigned long int的默认值 [英] taking default value of unsigned long int in unix
本文介绍了在unix中采用unsigned long int的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include每个头文件(我认为)
#included every header file (i think)
int main(int argc, char* argv[])
{
unsigned long long x=atoi(argv[1]);
unsigned long long y=atoi(argv[2]);
if(x>0 && x<=4294967295 && y>0 && y<=4294967295)
{
cout<<"done";
}
else
{
cout<<"not done";
}
return 0;
}
//但是当我插入x = 6543848485或大于2254354363(10位数)的任何值时...
//它会自动采用默认值x = 2147483647(自动)...我不y ...并没有进入else条件...
请帮助
// But when i insert x=6543848485 or any value greater than 2254354363(10 digit)...
// It is automatically taking the default value of x=2147483647(automatically)... I donot y... and not entering in the else condition...
please help
推荐答案
是否可能是因为atoi
返回了integer
?如带符号的32位数字? 2147483647恰好是十六进制的7FFFFFFF吗? IE.可以容纳带符号的32位整数的最大数字吗?
Could it possibly be becauseatoi
returns aninteger
? As in a signed, 32 bit quantity? And 2147483647 just happens to be 7FFFFFFF in hex? I.e. The largest number that fits in a signed, 32 bit integer?
atoi [ ^ ]是不合适的处理这么大的数字.使用 strtol [
atoi[^] is not appropriate for dealing with such big numbers. Use strtol[^] instead.
但是当我在Windows环境中运行该代码时.那么它运行得很好...
But when i run that code in Windows environment. then its running perfectly fine...
这篇关于在unix中采用unsigned long int的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文