I encountered a strange issue that I cannot quite understand. It has left me quite baffled. When I attempt to increase the number 9933272057275866 by 1, it somehow adds 2 instead!!! Here is the code snippet:
let test = 9933272057275866;
let test2 = test+1;
console.log('Before:', test);
console.log('After:', test2);
console.log('Sub:', test2-test);
Here is the output:
Before: 9933272057275866
After: 9933272057275868
Sub: 2
How is this even possible?
This issue occurred in a JavaScript environment. It first came to my attention when I encountered it on Hackerrank, and I then replicated it in my own node.js environment. The result was the same!
Can anyone explain what is going on here?