How can I know whether to round a quotient up or down (based on whether the number after the decimal point is 5+ or not) with ONLY this information?

4.9k Views Asked by At

Say I have a special calculator that, when it divides one number by another, it gives you the answer in the form of, "quotient r remainder." For example, if you divide 5 by 3, it tells you "1 remainder 2." I want to be able to take those 4 variables only (5 = divisor, 3 = denominator, 1 = quotient and 2 = remainder) and create a formula that lets me know to round the quotient up to 2.

You can multiply and divide by any additional numbers in the formula, but when you divide, you're restricted by the calculator in the same way, you can only get the "x remainder x" answer. You can't include information like, "if the first digit of variable x is..." You can only look at any number as a whole.

Not sure if it will help but I made some examples that round up and down to look for patterns.

Here are some examples of quotients that should be rounded up:
For 5/3:

Divisor = 5

Denominator = 3

Quotient = 1

Remainder = 2

Rounds up


For 7/4: Divisor = 7

Denominator = 4

Quotient = 1

Remainder = 3

Rounds up


8/5:
Divisor = 8

Denominator = 5

Quotient = 1

Remainder = 3

Rounds up


8/3:

Divisor = 8

Denominator = 3

Quotient = 2

Remainder = 2

Rounds up


For 9/5:

Divisor = 9

Denominator = 5

Quotient = 1

Remainder = 4

Rounds up

Here are some examples of quotients that should NOT be rounded up:


For 7/3:
Divisor = 7

Denominator = 3

Quotient = 2

Remainder = 1

Rounds down


For 8/2:

Divisor = 8

Denominator = 2

Quotient = 4

Remainder = 0

Rounds down


For 9/4:

Divisor = 9

Denominator = 4

Quotient = 2

Remainder = 1

Rounds down


1

There are 1 best solutions below

3
On BEST ANSWER

To exactly answer your question, the criteria becomes:

Is the remainder at least half of the divisor? If so, round up, otherwise round down.

That is to say, if you divide $X$ by $Y$ and get "$A$ remainder $B$", then if $2B\geq Y$, you should round up, and otherwise round down. You can check that this works on all your examples - and it's fairly clear, because this means that: $$\frac{X}Y=A+\frac{B}Y$$ and we are interested in whether that $\frac{B}Y$ term is closer to $0$ than to $1$ - which is equivalent to asking if it's greater than or equal to $\frac{1}2$.

Another way would be to add a number to $X$ before the division and discard the remainder after; in particular, if $Y$ is even, then if you divide $X+\frac{Y}2$ by $Y$, then whatever integer you get (discarding the remainder) is the desired answer. If $Y$ is odd, dividing $X+\frac{Y-1}2$ by $Y$ and discarding the remainder works. This works since, for instance, if we divide $X$ by $Y$ and get some result with a remainder less than $Y-1$, then dividing $X+1$ by $Y$ gives the same result, except with the remainder increased by $1$. If the remainder had been $Y-1$ previously, then this "rolls over" and increases the integer part of the quotient. Choosing to add $\frac{Y}2$ or $\frac{Y-1}2$ ensures that this "roll-over" coincides with how we'd like to round.