Skip to content
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 type of constants in ported sincosf #331

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Conversation

quaternic
Copy link
Contributor

When porting sincosf from musl, the double-precision constants used for range reduction were mistakenly (I assume) cast to f32, which led to inaccurate results in some cases.

// use crate::_eqf;

// #[test]
// fn with_pi() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does pi not pass anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the patched function now produces more accurate results, (sincosf(core::f32::consts::PI) = (-8.742278e-8, -1) ), the old test doesn't pass. I'm not really sure what to do with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. Maybe just delete the test and leave a NB comment for the module, in case we replace this with an implementation that handles it (or just special cases?)

@tgross35
Copy link
Contributor

Thanks, does this lower the ULP error around multiples of pi/2?

@quaternic
Copy link
Contributor Author

Yes. I've tested it on your mpfr-test-branch with the special casing for sincosf removed, and it seemed to pass everything. (Assuming I haven't missed some crucial thing and accidentally not tested it at all.)

@tgross35
Copy link
Contributor

Oh, awesome! Thanks for being thorough.

@tgross35 tgross35 merged commit 5b79b6d into rust-lang:master Oct 28, 2024
14 checks passed
@tgross35
Copy link
Contributor

Thanks!

@github-actions github-actions bot mentioned this pull request Oct 28, 2024
@quaternic quaternic deleted the sincosf branch October 28, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants