home | list info | list archive | date index | thread index

maximum integer value data type in C++11?

On 8/12/19 9:46 AM, Robert P. J. Day wrote:

>   was doing an online C++ evaluation test this morning and the last
> question required calculating some fairly sizable values (permutations
> of lengthy strings). didn't need to print any strings, just calculate
> the number of possible permutations, where the final value could be
> considerably more than 20! (20 factorial).

20! will fit in a 64-bit integer.

log_2 (20!) is about 61.1.  But you did say "considerably more", so... :)

>   even using unsigned long long, some test data exceeded the data
> type. wasn't sure if the test wanted me to switch to double float, or
> take advantage of a multi-precision library, or what, but am i correct
> in that "unsigned long long int" is the best i can get in terms of
> maximum value for an integral data type in C++?

I believe so.  gcc does support __int128_t on some architectures, but
it's not portable.  If you need portable support for more than 64 bits
of integer precision, you have to use a multiple-precision library.

Regards,

Dianne.

To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org

references