Types in C++ for large numbers -


i want calculate number of inversions big array, 200,000 ints, , number quite big. big can't stored in int value.

the answer -8,353,514,212, while simple cases works, think problem type of variable use store number of inversions.

i tried long int , output same, if try double 4.0755e+009 output. don't know problem is.

  1. use unsigned data type
  2. use unsigned long (usually 2^32-1) or unsigned long long (usually 2^64-1)

for full reference see this article.


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -