Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.

0 Members and 1 Guest are viewing this topic.

int integer_divide(int a, int b) { int neg = 1; int ret = 0; if (a < 0) { a = -a; neg = -neg; } if (b < 0) { b = -b; neg = -neg; } while (a >= b) { a -= b; ++ret; } return ret * neg;}

Any mathematical function beyond addition and subtraction must be done with a algorithm using addition and subtraction ONLY,