News for hackers. Stuff that matters.
Re:Sp.h is the standard library that C deserves by jcranmer on Saturday May 23, 2026 @12:46AM (#48244763)
"How bad can it be, I mean I know that numerics are not many people's strong suit, but..."

... ... ... oh wow, the math functions are really bad implementations. The range reduction on the sin/cos functions are yikes-level. Like the wrong input gives you an infinite loop level of yikes.

Re:Sp.h is the standard library that C deserves by lacewing on Saturday May 23, 2026 @01:07AM (#48244891)
Commendable accuracy, too: https://godbolt.org/z/s9haz611Y
Re:Sp.h is the standard library that C deserves by chrismorgan on Saturday May 23, 2026 @02:47AM (#48245328)
Here’s a diagram that very visibly shows the error: <https://www.wolframalpha.com/input?i=plot+y+%3D+sin%28x%29%2...>. And that’s even without accumulated float error if you start outside the range [−π, π] (huge numbers will just be wildly wrong).