Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I strongly suspect that in most cases, yes, you do. The only time you wouldn't pay this cost is if the multiplication outside of the sin() call and the multiplication inside of it can be constant folded together. That requires the call to sin() to have its code inlined at the callsite. Given how large most sin() implementations are, I would be fairly surprised if it does get inlined.

The only way to answer this is to profile it and see.



Even if it was inlined, I don't think compiler is allowed to rearrange floating-point calculations without -ffast-math or other scary flags.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: