I created a programming language for fun and now I want to write some basic math functions. The limitation I have is that the language only supports the integer data type. So I want to calculate 100 * sin(x). I've already managed to do the same thing with sqrt but I am stuck here. I've tried using the method described here: https://stackoverflow.com/a/2284929/6291515
And also a fast algorithm as described here: http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine-approximation/
I first tried modelling the algorithm in java (since it's easier to handle and debug) but it doesn't quite work. Maybe you have some idea on how to make it work.
int mult = 100;
int pi = (int)(Math.PI * (double) mult);
int x = (int)( 5 * (double) mult );
x = x % (2*pi);
int res=0, pow=x, fact=1, buf1 = pow;
for(int i=0; i<10; i++){
buf1 = pow;
buf1 /= fact;
res+=buf1;
pow*=x;
pow /= mult;
pow*=x;
pow /= mult;
pow*=-1;
fact*=(2*(i+1))*(2*(i+1)+1);
}