Interval for long type values:
-2,147,483,648 to 2,147,483,647
Try using long long instead, which uses 8 bytes and has an interval:
-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807
If you get the wrong results using a long time, try using double, but make sure you format the result correctly if you need to place it somewhere.
source share