I'm calculate sin by table.
Example fragment code bellow
.... #define Tabl_acos 0x80000000 ... ... double tsin (double arg) { double argout; unsigned int *adr;
adr = (unsigned int *)((unsigned int)Tabl_sin + (unsigned int)fabs(arg)*400); argout = *(double *)adr; return (argout); }
If I'm write ... + (unsigned int)fabs(arg)*400) -> result correct, but (arg) lose fraction right part and argout lose precition. If I'm write ... + (unsigned int)(fabs(arg)*400)) -> result incorrect! argout = fantastic value!!!
And a little footnote here.
The same lookup table can be used to compute both sin() and cos(), since there is just a difference of phase between sin() and cos().
And since a horisontal line through a circle shows that the upper and lower halves are mirrors, it's enough with a table of 180 degrees.
But since a vertical line through a circle shows that the left and right halves are mirrors, the table can be shrunk to only cover 90 degrees.
And since a diagonal line through the remaining quadrant shows that the two sides of the line are mirrors, the table can be shrunk to only cover 45 degrees. (This is sometimes used by fast circle drawing code to draw 8 dots at a time)
The calculation of the table index - and any adjustments of the retrieved value (additional sign or 1-lookup) - will obviously have to take into account which 45 degree part of the circle the input parameter related to. And take into account if sin() or cos() is computed.