??? 05/15/05 22:04 Modified: 05/15/05 22:06 Read: times Msg Score: +1 +1 Informative |
#93458 - sine function Responding to: ???'s previous message |
Hi Stanley,
There are two ways to do a sine function (or a cosine). One is to calculate the Taylor expansion series to whatever arbitrary precision you require. The second is to create a lookup table. As for calculating the average, you're just going to have to keep up with the number of addends in your sum. Assume for our purpose that you've dealt with (or will deal with) overflow issues and you have enough bits to do the arithmetic. Calculate the average by loading the first number into the accumulator and 1 into register B. Now add the second number to A, increment B to 2, and divide A by B. After n iterations you have the average of the first n numbers in your accumulator, A_n, and n is stored in B register. To find the average of the series with the (n+1)th number, add the (n+1)th number to the accumulator, increment the B register, and DIV AB. Continue as many times as needed, (up to n = 255). It's called a "running average." Hope this helps. Good luck. |
Topic | Author | Date |
Advance calculation and processing | 01/01/70 00:00 | |
It is easy | 01/01/70 00:00 | |
What if I persist? | 01/01/70 00:00 | |
ok | 01/01/70 00:00 | |
Not entirely sure | 01/01/70 00:00 | |
late night or miller time? | 01/01/70 00:00 | |
sine function | 01/01/70 00:00 | |
Correction | 01/01/70 00:00 | |
it works, but | 01/01/70 00:00 | |
Overflow ? | 01/01/70 00:00 | |
calrification![]() | 01/01/70 00:00 | |
Another sine alternative | 01/01/70 00:00 |