+ 2

Which datatype is to be used for handling values in range 10^18 in c++?

I have tried using Long long int, unsigned long long int But it fails for digits greater than 9

11th Jun 2020, 6:26 AM
Ashutosh Mulky
Ashutosh Mulky - avatar
8 Antworten
+ 3
You can use boost library. It can handel values beyond 2^64. For more details please check the link below. www.geeksforgeeks.org/advanced-c-boost-library/amp/ There is a rule by which you can calculate how many digit a data type can store and the logic is 2^10 = 10^3 (nearly) i.e as long long int is an 64 bit integer, it can support 18 digit number because 2^64 = 10^18(nearly) by the above rule. If you want to handle more digits, you can go for boost library.
12th Jun 2020, 5:01 AM
Bibhash Ghosh
Bibhash Ghosh - avatar
+ 4
11th Jun 2020, 5:13 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
But I think int will work just fine....
11th Jun 2020, 6:28 AM
Neba Emmanuel
Neba Emmanuel - avatar
+ 2
Thank you
11th Jun 2020, 10:12 AM
Ashutosh Mulky
Ashutosh Mulky - avatar
+ 2
~ swim ~ what is c++11 wht 11 denoting .
11th Jun 2020, 5:05 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
No, int cant handle such large values
11th Jun 2020, 6:29 AM
Ashutosh Mulky
Ashutosh Mulky - avatar