1
\$\begingroup\$

I am curious what would happen if you have a number such as 2 (10 in binary) and divide by 0 (0 in binary). What would happen?

\$\endgroup\$
1
  • \$\begingroup\$ Depends on the algorithm. Can you be more specific? \$\endgroup\$
    – Justme
    Mar 25, 2020 at 21:23

1 Answer 1

3
\$\begingroup\$

In the simplest versions it would enter an infinite loop because you repeatedly subtract divisor from the dividend until the dividend until the dividend is zero and count how many subtractions took place. But if the divisor is zero then the dividend never reaches zero so it continues trying forever:

Mechanical calculator dividing by zero

In better versions this is caught with a special case.

\$\endgroup\$
1
  • \$\begingroup\$ Ok, that makes sense. Interesting video too. \$\endgroup\$
    – Bob Joe
    Mar 25, 2020 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.