News for hackers. Stuff that matters.
Re:Faster asin() was hiding in plain sight by AlotOfReading on Wednesday March 11, 2026 @11:24AM (#47336842)
I'm pretty sure it's not faster, but it was fun to write:

    float asin(float x) {
      float x2 = 1.0f-fabs(x);
      u32 i = bitcast(x2);
      i = 0x5f3759df - (i>>1);
      float inv = bitcast(i);
      return copysign(pi/2-pi/2*(x2*inv),x);
    }
Courtesy of evil floating point bithacks.
Re:Faster asin() was hiding in plain sight by def-pri-pub on Wednesday March 11, 2026 @11:33AM (#47336962)
> floating point bithacks

The forbidden magic

Re:Faster asin() was hiding in plain sight by adampunk on Wednesday March 11, 2026 @12:09PM (#47337471)
// what the fuck
Re:Faster asin() was hiding in plain sight by chuckadams on Wednesday March 11, 2026 @11:36AM (#47336996)
You brought Zalgo. I blame this decade on you.
Re:Faster asin() was hiding in plain sight by moffkalast on Wednesday March 11, 2026 @11:43AM (#47337108)
> float asinine(float x) {

FTFY :P

Re:Faster asin() was hiding in plain sight by jacquesm on Wednesday March 11, 2026 @01:18PM (#47338396)
That could do with some subtitles.
Re:Faster asin() was hiding in plain sight by irishcoffee on Wednesday March 11, 2026 @01:45PM (#47338752)
Re:Faster asin() was hiding in plain sight by teo_zero on Thursday March 12, 2026 @02:35AM (#47347233)
The bad thing about this method is that it's slower than native CPU instructions. The good thing is that the result is very precise for at least 2 values of x, namely 1.0 and -1.0

JK

Re:Faster asin() was hiding in plain sight by AlotOfReading on Thursday March 12, 2026 @12:23PM (#47353232)
Yeah, it's an interesting approximation. It follows the shape of the curve pretty well except around 0, much better than low degree polynomials. Polynomial approximations have much better relative error bounds though.