1

I want to store a number "x" where 0<=x<=(10^18).

Which datatype should be used in C for storing such a large number?

I used "long int" but it's not working..

tod
  • 1,539
  • 4
  • 17
  • 43
user3608202
  • 79
  • 2
  • 10
  • 1
    use `uint64_t` with `#include `, `#include ` – BLUEPIXY May 06 '14 at 13:00
  • 1
    Can this be question be "de-duplicated"? This question involves "medium sized integers" and I'd say the correct answer is "`uint64_t`"; while the pretend duplicate question is completely different and does involve big numbers. – Brendan May 06 '14 at 13:07

1 Answers1

2

Use unsigned long long int. It is supported in C99 or later, and as a compiler extension in some pre-1999 compilers. and it must be able to hold at least 1.8 * 10^19 values.

M.M
  • 138,810
  • 21
  • 208
  • 365