Closed Bug 1380031 Opened 7 years ago Closed 5 years ago

Math.E not equal to Math.exp(1)

Categories

(Core :: JavaScript: Standard Library, defect, P3)

54 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox-esr60 --- wontfix
firefox57 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- fixed

People

(Reporter: scohen987, Assigned: anba)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170628075643

Steps to reproduce:

The constant Math.E (The number e) should be the same as Math.exp(1) (e^1=e), but Math.exp(1) has an extra (wrong) digit. Math.E is correct to 15 decimal places, Math.exp(1) has 16 decimal places, and the 16th digit is a 5, but the correct 16th digit would be 2. This leads to the unexpected result of Math.E being unequal to Math.exp(1)

console.log(Math.E, Math.exp(1), Math.E===Math.exp(1));


Actual results:

2.718281828459045, 2.7182818284590455, false


Expected results:

2.718281828459045, 2.718281828459045, true

It works as expected in Google's web browser.
Component: Untriaged → JavaScript: Standard Library
Product: Firefox → Core
now we're using imported fdlibm's exp function, and looks like the issue doesn't happen before fdlibm (bug 933257), at least on macOS 10.12.5.
we could either switch to system exp function or apply the same fix as v8.
Blocks: 933257
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
Hmm, I think it makes sense to apply the same fix as V8 did, because that way we don't have to worry about platform differences, which could be an issue if the system exp function is used.
Priority: -- → P3
P3, unassigned -> fix optional for 57
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0808c449b015
Ensure Math.exp(1) returns Math.E. r=arai

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
No longer blocks: 933257
Flags: in-testsuite+
Regressed by: 933257
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: