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

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -