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

Fixed the precision of expm1(float x) when x is small. #517

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ZERICO2005
Copy link
Contributor

The accuracy of expm1f(float x) has been fixed. It will return x when x is small for 12.0bits of precision, or it can return x + 0.5f * (x * x) when x is small for 16.0bits of precision. It falls-back to the naive return expf(x) - 1.0f when x is large.

…re provided, one with 12.0 bits of precision, and another with 16.0 bits of precision. Tested all inputs on x86_64
@@ -1,8 +1,24 @@
#include <math.h>

float expm1f(float x)
float expm1f(const float x)
Copy link
Member

Choose a reason for hiding this comment

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

Why? That's not needed or in the standard.

Copy link
Contributor Author

@ZERICO2005 ZERICO2005 Nov 9, 2024

Choose a reason for hiding this comment

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

Adding const to parameters passed by value doesn't change the ABI. It can prevent accidentally modifying the input, but it was a more of a micro optimization I added. It probably doesn't change the compiler output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants