-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Math.atanh
#1438
Fix Math.atanh
#1438
Conversation
db95a68
to
decb266
Compare
@@ -153,7 +153,7 @@ private static Object atanh(Context cx, Scriptable scope, Scriptable thisObj, Ob | |||
} | |||
return ScriptRuntime.negativeZeroObj; | |||
} | |||
return Double.valueOf(0.5 * Math.log((x + 1.0) / (x - 1.0))); | |||
return Double.valueOf(0.5 * Math.log((x + 1.0) / (1.0 - x))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe pedantic but to be in sync with MDN
return Double.valueOf(0.5 * Math.log((1.0 + x) / (1.0 - x)));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -54,4 +54,78 @@ assertEquals(Math.imul(-2, -2), 4); | |||
assertEquals(Math.imul(0xffffffff, 5), -5); | |||
assertEquals(Math.imul(0xfffffffe, 5), -10); | |||
|
|||
assertEqualsDelta(Math.atanh(1/2), 0.549306144334059, 0.0000000000001); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the 262 tests suite seems to have no tests for this maybe you can add some more samples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
assertEquals(Math.sign('foo'), NaN); | ||
assertEquals(Math.sign(), NaN); | ||
|
||
assertEquals(Math.clz32(0), 32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a separate PR #1430 for clz32, maybe we have to merge the two different approaches of tests for the functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed all the cases from this file - it seems the other PR will add complete coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the changes, this one is fine for me
Looks good to me, and nice catch. Thanks! |
See #1437
I have added also some tests for various "recent" math functions that seemed to be lacking them.