![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) | |
| Quote:
(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. | ||
| |
| | (permalink) |
| 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 | |
| |