PIC Division (multiplication of inverse)

THE_RB

Joined Feb 11, 2008
5,438
...
Range of values:
C: b 0000 0000 0000 0000.0000 0001 - b 1111 1111 1111 1111.1111 1111 (note binary point)
A: b 0000 0000 0000 0001 - b 1111 1111 1111 1111
B: b 0000 0001 - b 1111 1111
...
What you basially have is a division with a 24bit result. So it's a 24bit division, or more precisely you multiply A by 256 (increase A from 16bits to 24bits) then you do a 24bit / 8bit division with a 24bit result.

To again use the successive subtraction analogy you would do this;
Rich (BB code):
//(psuedo code);
C = 0
A = (A * 256)    // scales A from 16bit up to 24bit
while(A >= B)    // 24bit / 8bit division by successive subtraction
{
  A = (A - B)
  C = (C + 1)  
}
and the result is in your desired 24bit format;
xxxxxxxx xxxxxxxx . xxxxxxxx
 

derser

Joined Mar 25, 2013
3
Hi.My name is Barosov.I am from Bulgaria.I have tested your code.I made comparison betweenmy code and yours,Yours ismuch faster.Just like you iprefer to write program codemyself.Would you mind to explainyour code in more datails?I trayto write to my self.Bestregards;,<SNIP>
 
Last edited by a moderator:

ErnieM

Joined Apr 24, 2011
8,377
Hi derser/Barosov (but we'll just call you "derser" from now on to keep it friendly).

Welcome to the forum!

Which code do you refer? Could we have a hint what you are trying to accomplish?

Also, perhaps starting your own post or thread would help you better. That way everyone is aiming at your specific problem.

(And as bertrus hinted... NEVER put your email in a public forum, not unless you want your Nigerian uncle to offer you millions of dollars, just sent him 1000 for the processing fee first.)
 

atferrari

Joined Jan 6, 2004
4,768
(And as bertrus hinted... NEVER put your email in a public forum, not unless you want your Nigerian uncle to offer you millions of dollars, just sent him 1000 for the processing fee first.)
I sent that amount, twice already. Now, just waiting for money to come. Hope and time.. :D
 
Top