I'm a junior dev doing react(-native) and Node.js things always looking for new and interesting technologies and challenges, currently working as an apprentice 🙋🏼♂️
At first, I was confused why this would not return false, but of course you wouldn't have posted this if it would return false. 😃
While looking into why these statements are evaluated to be equal, I stumbled upon an even more interesting problem: When you try to enter exceedingly big numbers into a JavaScript console, they will be returned similiarly but not with the exact same value. For example, 9007199254740992111 will be transformed into 9007199254740992000. This sounded awfully like floating point issues. After having a look, the way integers are stored in JavaScript engines using 64 bits, which means there's a limit to correctly display numbers above a certain threshold. And that threshold appears to be 2^53, which explains why you took those parameters for Math.pow!
Previously, I was only aware of examples where floating point issues arise with the storage of numbers smaller than zero, leading me to think it would be a "comma problem" (for example 0.1 + 0.2 != 0.3), but this example made clear for me that this of course can also happen for big numbers.
This thread helped me understand the details, it's worth checking out.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
At first, I was confused why this would not return
false
, but of course you wouldn't have posted this if it would returnfalse
. 😃While looking into why these statements are evaluated to be equal, I stumbled upon an even more interesting problem: When you try to enter exceedingly big numbers into a JavaScript console, they will be returned similiarly but not with the exact same value. For example,
9007199254740992111
will be transformed into9007199254740992000
. This sounded awfully like floating point issues. After having a look, the way integers are stored in JavaScript engines using 64 bits, which means there's a limit to correctly display numbers above a certain threshold. And that threshold appears to be 2^53, which explains why you took those parameters forMath.pow
!Previously, I was only aware of examples where floating point issues arise with the storage of numbers smaller than zero, leading me to think it would be a "comma problem" (for example
0.1 + 0.2 != 0.3
), but this example made clear for me that this of course can also happen for big numbers.This thread helped me understand the details, it's worth checking out.