Why would one HAVE to use -0? -0 is flawed, since, 0 is neutral, it doesn't have a sign.
Take 1 for example, 1 == +1 since 1 has the + sign, where as with 0, is not +0 because 0 has no sign. So 0 === -0 being true is actually one of the few places where JS is right.
Hi Tomaz, I’m not talking about why ... I just show a fact 🙂 I never use -0 in my life but I am not God I am just a person.
Use or not it’s up to you 🙂
When will you need to compare
0
and-0
, as both are just floating points?For
NaN
, well, there is nothing I can do about it...Always when you decide to use 0 and -0 in your program. I hope you never have to use -0 but it's up to you 🙂.
Why would one HAVE to use -0? -0 is flawed, since, 0 is neutral, it doesn't have a sign.
Take 1 for example, 1 == +1 since 1 has the + sign, where as with 0, is not +0 because 0 has no sign. So 0 === -0 being true is actually one of the few places where JS is right.
Hi Tomaz, I’m not talking about why ... I just show a fact 🙂 I never use -0 in my life but I am not God I am just a person.
Use or not it’s up to you 🙂
0.1 + 0.2 !== 0.3
is headache enough, but now just let1 - 1 === -1 + 1
, please.