I want to implement perfomance-sensitive integral calculations in C#. I was told that function int Sin(int angle) that returns a value between -256 and 255 is useful in this situation, since I don’t need it to be exact. Is there a good implementation of such a function that I can use, or some algorithm that I can implement?
I want to implement perfomance-sensitive integral calculations in C#. I was told that function
Share
It’s just a lookup table. Just create the table using the built-in sin function at startup, and write your function to lookup into that table. Here is a question which is basically the same, your function would just take an int rather than a double:
Fast Sin/Cos using a pre computed translation array
This answer also uses unsafe code to get a bit of extra speed, but you can just use a normal array if you don’t want unsafe code