[linux] maximum integer value data type in C++11?

2019-08-12 Thread Dianne Skoll
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+unsubscr...@linux-ottawa.org
To get help send a blank message to linux+h...@linux-ottawa.org
To visit the archives: https://lists.linux-ottawa.org



[linux] maximum integer value data type in C++11?

2019-08-12 Thread Robert P. J. Day


  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).

  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++?

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
 http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday


To unsubscribe send a blank message to linux+unsubscr...@linux-ottawa.org
To get help send a blank message to linux+h...@linux-ottawa.org
To visit the archives: https://lists.linux-ottawa.org