use libm for acosh and asinh for f16, f32, and f64#154051
use libm for acosh and asinh for f16, f32, and f64#154051malezjaa wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @joboet rustbot has assigned @joboet. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Hello @malezjaa, |
|
I'm really sorry about that. I should've checked If anyone was already assigned to this issue. I'll do that from now on. |
This comment has been minimized.
This comment has been minimized.
4a67c1e to
90a7256
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Happy to review this or alternatives, unless you have a preference @joboet r? tgross35 |
Can we just call libm via the Can you also clarify what approximations you are referencing? This isn't what is in https://github.com/rust-lang/compiler-builtins/blob/644346f0541f74fc425070f8e0712f2dac898e11/libm/src/math/acosh.rs. |
3a210bb to
538e681
Compare
|
Oh yeah that makes sense. I'll update the PR title and description to show that we're now using libm for these functions. |
This comment has been minimized.
This comment has been minimized.
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
538e681 to
abd315c
Compare
|
The Miri subtree was changed cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
|
Oh wait, this was for the |
|
It probably has to do with this: rust/src/tools/miri/tests/pass/float.rs Lines 1602 to 1605 in 37cfa17 You can move the new cases into that |
|
@rustbot ready |
These are supported in glibc, which is pretty much the only libc to support f128 math for now, |
2332619 to
30e7816
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
For reference, I usually use Julia for this quick arbitrary-precision number crunching. Set to MANTISSA_DIGITS then test with MAX.
julia> setprecision(113)
113
julia> x=parse(BigFloat, "1.18973149535723176508575932662800702e+4932")
1.18973149535723176508575932662800702e+4932
julia> asinh(x)
11357.216553474703894801348310092223
julia> asinh(big(1.7976931348623157e+308))
710.475860073943942041640622032115338
julia> setprecision(53)
53
julia> asinh(big(1.7976931348623157e+308))
710.47586007394398
julia> setprecision(24)
24
julia> asinh(big(3.40282347e+38))
89.4159851
julia> setprecision(11)
11
julia> asinh(big(6.5504e+4))
11.78130e7816 to
e83e484
Compare
|
Nice. Thank you for the correct values :D |
…asinh, r=tgross35 use libm for acosh and asinh for f16, f32, and f64 Fixes rust-lang#153878 Uses libm for `acosh` and `asinh` for `f16`, `f32`, and `f64`. I didn't change impl for f128 as i couldn't find existing function for these in libm
|
Should I just increase ASINH_APPROX, ACOSH_APPROX thresholds for x86 or is that not the solution? |
|
Ah yeah, i586 has all kinds of issues with floating point accuracy. I would do this as: /// i586 has issues with floating point precision.
const I586: bool = cfg!(target_arch = "x86") && cfg!(not(target_feature = "sse2"));
impl ... {
const ASINH_APPROX: Self = if i586 { /* relaxed precision */ } else { /* current precision */ };
}Make the precision larger than what showed up in the tests to leave some flexibility in the future. |
|
Oh also, is this only for f32 or for other types too? |
|
Usually that applies to f32 and f64 (not f16/f128 since they don't have the same ABI), but I guess the f64 precision is already relaxed enough. |
View all comments
Fixes #153878
Uses libm for
acoshandasinhforf16,f32, andf64.I didn't change impl for f128 as i couldn't find existing function for these in libm