how the computer multiplies or divides? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how the computer multiplies or divides?

do I know that when adding, the computer adds the bits with the help of some gates, and could someone help with the multiplication division?

20th Jul 2020, 6:08 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
5 Answers
+ 3
Better search on Google for "How an ALU works". There is plenty of information available.
20th Jul 2020, 6:37 PM
Vasile Eftodii
Vasile Eftodii - avatar
+ 3
The long explanation converted into short code: https://code.sololearn.com/cl74QmLjwbGO/?ref=app
20th Jul 2020, 9:39 PM
Seb TheS
Seb TheS - avatar
+ 2
This is how I think computer calculates division, I think it os based on testing results with *. If: numerator / denominator = quotient Then: denominator * quotient = numerator Computer could use this information to calculate the division result. Computer would start with 4 variables: nominator, denominator, quotient = 0 counter = 1 Computer would start a loop with undefined break. In each iteration it would compare the nominator to this expressiln: quotient + counter * denominator If the nominator is equal to the expression, this will be added to the quotient: counter * denominator and the loop would be broken. If the nominator is less than the expression, the counter would be divided by 2 using >> and the loop would continue from the next iteration. If the nominator is greater than the expression this would be added to the quotient: counter * denominator after that counter would be multiplied by 2 and loop continues to the next iteration.
20th Jul 2020, 6:44 PM
Seb TheS
Seb TheS - avatar
+ 1
What is an ALU?, sorry just i am a student, and i now sutdy at home
20th Jul 2020, 6:41 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 1
ALU stands for "arithmetic logic unit".
20th Jul 2020, 7:55 PM
Vasile Eftodii
Vasile Eftodii - avatar