Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 19th January 2004, 10:27 AM   (permalink)
Default is it possible

i would like to do 8 bit division 2/5 and add quotient 0.4 with some integer value (for example 3) then result is 3.4.

what is the procedure for the above calculation. can anybody know algorithm or program?
plz send it to me immediately
finst is offline  
Old 19th January 2004, 10:43 AM   (permalink)
Default Re: is it possible

Quote:
Originally Posted by finst
i would like to do 8 bit division 2/5 and add quotient 0.4 with some integer value (for example 3) then result is 3.4.

what is the procedure for the above calculation. can anybody know algorithm or program?
plz send it to me immediately
I'm not very sure what you're wanting?, you've already given what you need - calling the three values x, y, and z you need to calculate:

(x/y) + z

As it's a fixed calculation, do it in two stages, first divide x by y, then add z to the result.

You don't mention what language you are wanting to use, nor what system it's for - so anything else would only be speculation.
Nigel Goodwin is offline  
Old 19th January 2004, 10:44 AM   (permalink)
Default

scale the division so you can work with integers. For example make it
20 / 5 wich is 4 then add 30 so the result will be 34. If you print the value on a display you can just add a decimal point beween the 3 and 4.

Pic's aren't very good at math, specially floating point.

For code snippets about multiplying and dividing go to the pic list
www.piclist.com
Exo is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 06:33 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker