English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Ok, so you can multiply by addition, example would be 3*5=15 or by addition just go 5+5+5=15. So can this be done with division and subtraction? I want to divide x and y (x/y) but I can't use division so how do I do it? Thanks for any help you can provide.
BTW: I'm writing a program for a microcontroler and it doesn't have a divide function, it can add, subtract, multiply, shift left or right but it cannot divide.

2007-06-19 09:09:54 · 2 answers · asked by stingray4540 2 in Education & Reference Homework Help

2 answers

I would write a loop where
y is subtracted from x
and if the difference is still greater than y,
then you loop around and repeat
and subtract again
until you get a number less than y.
So this is either 0 or a remainder less than y.
And the loop would have a counter to keep
track of how many times you subtracted.

Note: if you want decimal places,
you would have to take the remainder and find a way to
convert into decimals. Like multiplying by 10 or 100 or 1000
and then doing the division steps again by subtracting, and then moving the decimal if that is what you mean by shifting left or right.

2007-06-19 09:47:06 · answer #1 · answered by Nghiem E 4 · 1 0

what about 19-5-5-5=0+4

2007-06-19 16:18:55 · answer #2 · answered by don n 6 · 0 0

fedest.com, questions and answers