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

Author: Ya Ch (Company: frau) (cherry)
Posted on:

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


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 

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:

Rate this post
0 useful
not useful
maybe using 32 bit math is a simple way, look at
here some 32 bit asm...


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.