eponymous
eponymous

Reputation: 2228

which data type correspond to 10^16 in C++?

My C++ programme may create a value until 10^16 during the run time, I tried to use "long long int" for it but it didn't work. Which data type correspond to 10^16?

Thanks;

Upvotes: 0

Views: 6743

Answers (4)

Varad
Varad

Reputation: 1

Unsigned long long Int works up-to 10^18!

Upvotes: -2

Kerrek SB
Kerrek SB

Reputation: 476950

Try int64_t. That should be long enough. But be sure to enter an integer literal:

int64_t n = 10000000000000000;

If you say 1E16, that's a double literal, and the conversion to integer may produce unexpected results.

Upvotes: 1

Joseph Mansfield
Joseph Mansfield

Reputation: 110648

The minimum guaranteed maximum of long long int is 2^63 - 1, which is approximately 10^19. It should be fine. To be sure, use the std::int_least64_t type from <cstdint>. It is guaranteed to have at least 64 bits.

Upvotes: 6

Alon
Alon

Reputation: 1804

less than 64bit so.. long long should be good..

Upvotes: 1

Related Questions