mozilla::DoublesAreIdentical (equates NaNs, doesn't equate +0 to -0, otherwise normal equality)

RESOLVED FIXED in mozilla25

Status

()

Core
MFBT
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

unspecified
mozilla25
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 779558 [details] [diff] [review]
Patch
Attachment #779558 - Flags: review?(luke)

Comment 1

4 years ago
Comment on attachment 779558 [details] [diff] [review]
Patch

I was on the edge of whether "identical" should conflate the NaN space, but I think it does make sense.  If you really really mean "same bits", you can use BitwiseCast.  Otherwise, "identical" means what we all expect == to mean.
Attachment #779558 - Flags: review?(luke) → review+

Comment 2

4 years ago
What's the use case for this function?
https://hg.mozilla.org/integration/mozilla-inbound/rev/90543abea431

The use case is any time you want to compare two doubles in the behave-identically sense.  The changed case here is one example of that.  Another is the following:

  var obj = {};
  Object.defineProperty(obj, "foo",
                        { value: NaN, writable: false, configurable: false });
  Object.defineProperty(obj, "foo", { value: NaN }); // no change, so shouldn't throw

(It happens that the underlying SameValue method we use to implement that is written in a way such that this method isn't useful there, but the concept applies.)

This isn't a super-common need, but it shows up from time to time, and this is clearly the place for it.
Target Milestone: --- → mozilla25
https://hg.mozilla.org/mozilla-central/rev/90543abea431
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.