4 ms·
> One point which often bites people which isn't highlighted in this article, is that due to having an explicit sign bit 0 and -0 have different encodings, but
by vbezhenar 4y ago
> One point which often bites people which isn't highlighted in this article, is that due to having an explicit sign bit 0 and -0 have different encodings, but in most cases you'll want them to compare equal. So just comparing the bits won't do.
How does JS do it? (0 / -1) === (0 / 1) is true.
- TAForObvReasons 4y agoconst n = 0/-1, p = 0/1; n === p; // true 1/n === 1/p; // false 1/n === -Infinity; // true 1/p === Infinity; // true Infinity === -Infinity; // false