-
Notifications
You must be signed in to change notification settings - Fork 96
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
feat: use Math for double::{ln,log2,log10} on JS #1489
Conversation
Looking at the git diff, I can point out the following potential issues:
These issues don't affect the functionality of the code directly but could impact maintainability and documentation accuracy. |
Pull Request Test Coverage Report for Build 5042Details
💛 - Coveralls |
e6e0f99
to
9cb3a29
Compare
I noticed that // current version
pub fn log10(self : Double) -> Double {
ln(self) / ln10
} May I propose an improved version with better precision, which I have tested locally and found to perform well? pub fn log10(x: Double) -> Double {
if x < 0 || x.is_nan() {
return not_a_number
}
if x.is_inf() {
return x
}
let ivln10 = 4.34294481903251816668e-01
let log10_2hi = 3.01029995663611771306e-01
let log10_2lo = 3.69423907715893078616e-13
let (f, e) = frexp(x)
let (f, e) = if e >= 1 {
(f * 2.0, (e - 1).to_double())
} else {
(f, e.to_double())
}
let z = e * log10_2lo + ivln10 * log(f)
z + e * log10_2hi
} |
@Kaida-Amethyst Thank you for your proposal! Could you please open a PR for that? |
Ok, No probelm 👌🏻 , gonna post a PR soon 😸 |
PR link: #1499 😸 |
9cb3a29
to
ae2b3fe
Compare
ae2b3fe
to
92dd619
Compare
Follow up of #1485 .
This PR use
Math
library on JS backend to implement:Double::ln
Double::log2
Double::log10
TODO:
15.0.log10()
is now inconsistent between JS & Other platforms.