View Single Post
Old 29 June 2008, 02:10   #9
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Ah! Found it in one of my yellowed notebooks...

sin x = x - (x^3 / 3!) + (x^5 / 5!) - (x^7 / 7!) + (x^9 / 9!) ...

where ^ is "raised to the power of", ie. x^3 = x*x*x

and ! is factorial, ie. 4!=1*2*3*4


Didn't find the asm for it, though. IIRC the angle x was in radians as a signed 16-bit integer and I swapped it down for each "power" except last, and then I had a simple list of precalced factorials longwords, shifted to keep the accumulated sum of quotients within longword bounds.

The result was a signed integer where "1" was $7fffffff, and I think you got one "bit" of result precision for two iterations, so 32 iterations should give 16 bits precision, i.e. 4-5 decimal places.
Photon is offline  
 
Page generated in 0.09047 seconds with 11 queries