Three people come into a restaurant and order 4 pitchers of beer at $10.00 each. They ask for separate checks.

I am trying to figure out the best way to display the quantity to the customer. Ideally I would like to show them the quantity as "1 1/3".

I found a custom function that converts decimals to fractions but it's returning "1 21/64".

Can someone please explain how to resolve this issue?

Thanks.

I think this is being significantly overthought. No mucking about with decimals is necessary at all, much less converting between decimals and fractions!

If you want to evenly divide the bill, or a portion thereof, and display the result as a fraction, you'll always want to divide by the number of people. Are you familiar with the MOD function?

Here I've worked through this bit by bit so you (hopefully) understand how and why I arrived at the formula at the end. I'm sure my old math teacher would be proud.

p = number of people

n = number of items to be divided

S = share of n to each person (whole number only)

s = share of n to each person (fraction only)

Case 1: Assume n > p (e.g. 8 pitchers, 3 people)

This yields a problem if there are fewer items than people:

Case 2: Assume n < p (e.g. 3 pitchers, 4 people)

There is also a problem if the number of people divides evenly into the number of items:

Case 3: There is an even number of people (e.g. 6 pitchers, 3 people)

Lastly, we need to deal with simplifying the resulting fraction:

Case 4: The fraction needs to be simplified (e.g. 10 pitchers, 6 people)

I think that covers all cases.

Time to put this all together into one calculation:

Note:

- The result is text, not a number, but I suspect that's what you want since you can simply use "n/p" as a multiplier with the Round () function to calculate prices.

- I changed S and s to W and f for Whole and fraction because FM didn't like S and s

- $n and $p can be defined as variables (as I did for the purposes of testing this formula), or you can simply have them defined as parameters of a custom function of Share ( n ; p ) and dispense with the first two lines.

If 14 people order 45 items, it'll return the odd fraction "3 3/14" but I can't see any way around that and I suspect that's what you'd want anyway since it is true.

- RG>