CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Fast Integer Division

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eli_Iceman
Guest







Fast Integer Division
PostPosted: Mon Apr 19, 2004 11:01 am     Reply with quote

Hi
Is there any way of dividing two 16bit integers, a and b (where a<b and b != 0) without recieving a floating point number but instead a fraction with a denominator of 2^16. Something similar to motorola's FDIV. I'm using an 18f6720. (i couldn't find anything on other posts but maybe i missed something...)
Thanks
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Mon Apr 19, 2004 12:10 pm     Reply with quote

x=a/b

is the same as

x*2^16=(a*2^16)/b

To do this you must perform 32 bit division. I don't know what it benifit's you but it will work.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group