-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
AK: fmod(), sin(), cos(), atan2() for non-x86 #25578
Conversation
Huh, looks like you're right! Are the macOS lagom bots running on arm machines? Must be, I suppose? |
Yeah GitHub has a load of racks of re-housed mac minis they use for the macOS free tier |
Locally, it seems removing the sin/cos libcall is at fault. I put those back, let's see what CI says. |
This is a pretty naive implementation, but it mostly works.
Now that we have fmod(), we can implement some symmetries for sin() and cos(). The core approximation is still very simplistic, but now it only has to approximate in [0, Pi/2]. So while its error is still high, it's no longer unbounded.
With this, sin() and cos() are fairly close to the correct values for all x. It's neither fast nor very accurate, but much better than what we had before.
atan() isn't implemented yet on non-x86, so this isn't super useful yet. But it does handle a couple corner cases correctly already, and those are even enough to make all the atan2 tests in Tests/LibC/TestMath.cpp pass 🙃
css-gradients.png was different with the atan2 change. (From manually eyeing the diff, in harmless ways, but I didn't expect the atan2 change to change behavior at all, so I want to investigate that a bit.) I put back the libcalls for both atan2 and fmod for now since replacing the non-serenity codepath isn't the main thrust of this PR. I still want to do this in a future PR, but it doesn't have to be in here. |
atan2() is implemented in terms of atan(), so the implementation isn't super useful yet.