What kind of data type should I use for this 600851475143 in c ++?

i'm using c++, even if i declare long int, there is error like......

long int  num = 600851475143;

 warning: integer constant is too large for ‘long’ type

which datatype should be used in this case?

A lot of it depends on the platform and compiler you are using.

If you are on a x64 platform, a long datatype in C++ should work. A signed long ranges from −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. An unsigned long on the other hand ranges from 0 to +18,446,744,073,709,551,615.

Also depending on the compiler and platform there are a few other datatypes which effectively is the same thing (doubleword, longword, long long, quad, quadword, int64).

C (not C++) supports the long long data type. Say if you are on Fedora 10 x32 then gcc 4.3.0 supports the long long datatype but you must put the LL after the large literal. See http://www.daniweb.com/forums/thread162930-2.html

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章