开发者

What is the biggest numerical primitive datatype in C++ (old/new standard)

I am a bit confused about old/new so that's my question. What is the biggest numerical primitive datatype in the old and in the new C++ standar开发者_C百科d? (integer and floatingpoint)

regards & many thanks in advance

Oops


In the 1998 standard, long int and unsigned long int are the types that are at least as big as any of the standard's other integral types (§3.9.1/2-3). (They may or may not be "the biggest" types. It's possible for long int to be the same size as int, for instance. For that matter, char could be the same size, too.) The floating-point long double provides at least as much precision as the other two floating-point types (§3.9.1/8).

In the draft standard for C++0x (n3092), the types are long long int and unsigned long long int (§3.9.1/2-3). The most precise floating-point type remains long double (§3.9.1/8).

Implementations may provide bigger types beyond what the standard calls for. Check the documentation for details on that.


Have a look at

C and C++ Data Types

Data Type Ranges

Variables. Data Types. section Fundamental data types


In C++03, long [int] and unsigned long [int] have greatest integral range and long double has greatest FP precision and range.

In C++0x, intmax_t and uintmax_t have greatest integral range, and may even be bigger than long long. For example, it would be reasonable for an implementation to make both long and long long 64-bit and make intmax_t 128-bit.

intmax_t is merely being adopted from C99, so if your implementation supports C99, you don't need to require C++0x. Simply include stdint.h instead of cstdint. Use of "C-style" headers is perfectly safe anyway, although I'm not sure if there's a good way to check for C99 typedefs within C++.

Precisely or conveniently named floating point types were not introduced with C99 or C++0x, so do avoid anything like float64_t or floatmax_t if you want portability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜