News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

average algorithm

Started by Moof, December 20, 2004, 05:28:07 PM

Previous topic - Next topic

Moof

Anyone has it, real mode, 16 bit registers

Jibz

Hmm .. what do you mean by average algorithm? Sum some numbers together and divide them by how many there were?

Sounds a bit like a homework assignment :wink.

roticv

I am really amused since you called finding an average an algorithm.  :toothy

Tedd

Average: (element1 + element2 + ele.....) DIV (number of elements)

This is about as obvious as it gets.

At least have a go - you might even learn something ;)
No snowflake in an avalanche feels responsible.

hador

Hi...

if you want more complicate algorithm take a look this:

avg_b[1] = a1/1

avg_b[2] = (a1+a2)/2 = ((1*a1/1)+a2)/2 = (1*avg_b[1]+a2)/2

avg_b[3] = (a1+a2+a3)/3 = ((2*((a1+a2)/2))+a3)/3 =(2*avg_b[2]+a3)/3

...
...

avg_b[n] = ((n-1)*avg_b[n-1]+an)/n


--HadorĀ  :8)