-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
floating point log
methods do not round correctly
#47273
Comments
There is no LLVM intrinsic for logarithms to an arbitrary base, probably because IEEE754 does not include that in its list of recommended correctly rounded functions. So maybe it's not a good idea to try to implement this with correct rounding. However, considering that the other transcendental functions are correctly rounded, the documentation should clearly state that the
|
doc: show that `f32::log` and `f64::log` are not correctly rounded Fixes rust-lang#47273. One thing I'm not sure about is whether the "calculated as `self.ln() / base.ln()`" bit is being too specific, maybe we do not want to make this such a strong commitment. I think it's fine, but we should not make commitments in the API documentation by accident. In case that is removed, the added sentence "`self.log2()` can ... base 10." still makes it amply clear that the `log` methods can be more inaccurate than other methods. If the above clause is removed, this second sentence can be moved to the first paragraph, kind of like the accuracy comment for the [`mul_add`](https://doc.rust-lang.org/std/primitive.f32.html#method.mul_add) method.
doc: show that `f32::log` and `f64::log` are not correctly rounded Fixes rust-lang#47273. One thing I'm not sure about is whether the "calculated as `self.ln() / base.ln()`" bit is being too specific, maybe we do not want to make this such a strong commitment. I think it's fine, but we should not make commitments in the API documentation by accident. In case that is removed, the added sentence "`self.log2()` can ... base 10." still makes it amply clear that the `log` methods can be more inaccurate than other methods. If the above clause is removed, this second sentence can be moved to the first paragraph, kind of like the accuracy comment for the [`mul_add`](https://doc.rust-lang.org/std/primitive.f32.html#method.mul_add) method.
The methods
f32::log
andf64::log
do not round correctly. As a trivial example, this codeoutputs
The text was updated successfully, but these errors were encountered: