# Forum: µC & Digital Electronics 16 bit division with high precision problem?

 Author: Ya Ch (Company: frau) (cherry) Posted on: 2007-06-18 17:28

Rate this post
 0 ▲ useful ▼ not useful
Hi, all

I use mega128 to control ad5933 chip, since now it's the last step of my
whole project, sticking with assembly language is a better option.

I am doing damage matrix between two column of data, after I simplified
the equation, actually I just need to calculate undamage/damage, they
are all 16bit numbers, and because they are very close numbers, I have
to divide out 4 or 5 decimal until I can see the difference, for
instance(I calculated in MATLAB):

UN_1/DA_1 = 0.9993
UN_2/DA_2 = 1.0208

etc...

1. I read AVR200 unsigned 16bits division carefully, I think I can put
the decimal in the remainder, right?
Later I will do (UN/DA)^2, assume I already save UN/DA, since mega128
has fractional multiplication, I'd like to take advantage of it. so how
could I convert this remainder into fractional.

2. And how many digits of remainder I need to reserve for this
precision.

Hope someone with experience could explain to me my questions, I am
really getting lost right now.

: Moved by Admin
 Author: Düsentrieb (Guest) Posted on: 2007-06-18 21:22

Rate this post
 0 ▲ useful ▼ not useful
maybe using 32 bit math is a simple way, look at
http://www.sump.org/projects/counter/
here some 32 bit asm...

• $formula (LaTeX syntax)$