How to fix an error in your database
To fix the error in your database, you can make the following addition to all errors:
long new_result = old_buggy_result + 1309965025280L;
A constant number was found as follows:
- Check the value of the buggy
result - Indicate what should be in the correct value of
result ? - Add a buggy
result value to find the correct result.
But this is only possible if you saved sample and offset in your database or somewhere else.
Otherwise, it depends on the number of wrappers that occurred during the initial calculation:
long size_of_int = (long)Math.pow(2, 32); int number_of_wraps = 305
If the numbers in your database are close enough to your sample, that means you can do higher using 305 as the number of wrappers.
Error explanation (for future readers)
Operation here:
(sample + offset) * 1000;
computed using int , not long . But the result is "too large" to be stored in the int variable. That's why you have an overflow.
Change it to:
((long) sample + offset) * 1000L;
So, now the + and * operations will be performed using long values, and the result will have a long value that will not overflow.
source share