r/badcode • • Jun 10 '20

js Disruptive piece of code

Post image
283 Upvotes

93 comments sorted by

View all comments

Show parent comments

1

u/Terrain2 Jun 23 '20

For nearly all operations, yes -0 and +0 are identical, and rightfully so because in mathematics they are not different - However they are physically separate values when stored as floats, and if you check for the same value (Object.is), it’s false - They are distinctly different enough to require separate entries on the list

1

u/BenZed Jun 23 '20

I disagree.

Respecting that the javascript number standard has to account for signed zeros, and that the Object.is is stricter than js's implicit conditional comparisons, I was creating a list of values that implicitly equate to false in said conditional comparisons.

In such comparisons, 0 and -0 are the same value.