0
$\begingroup$

What's the best way to split the decimal prices and quantities to a whole number representation?

E.g.

100 Banana at $\6.3 each, and the seller doesn't accept cents.

I am splitting this using following logic:

Take 6 and immediate next number (7) as prices. So 6Q_1 + 7Q_2 = 630 ~~\text{ and }~~ Q_1+Q_2=100\cdots$ Solving this gives me $Q_1=70$ at $\$6 each and $Q_2=30$ at $\$$7 each.

Is there a better mathematical model to solve this splitting problem accurately for any decimal and quantity?

  • 0
    We use dollar signs for $\LaTeX$ (mathematical markup) on MSE. To display an actual dollar sign, one must use `$\$$` (the first and last dollar signs are delimeters, and `\$` is the markup for a dollar sign).2012-04-20

1 Answers 1

0

More generally, you have $n$ bananas at $d$ dollars each, where $nd$ is a whole number. Let $a$ be the greatest integer not exceeding $d$. You propose taking $a$ and $a+1$ as prices, and you are looking for $x$ and $y$ satisfying $\eqalign{ax+(a+1)y&=nd\cr x+y&=n\cr}$ This system has the solution $x=(a+1-d)n,\quad y=(d-a)n$ This says that $n$ bananas at $d$ dollars each amounts to the same thing as $(a+1-d)n$ bananas at $a$ dollars each and $(d-a)n$ bananas at $a+1$ dollars each.

In your example, you have $n=100,d=6.3$ which yields $a=6$, so 70 at 6 dollars and 30 at 7.

  • 0
    33 bananas at 3.3 dollars each comes to 108.9 dollars total, which isn't a whole number, which means an answer like the one in the original question is impossible. You can round it up to 109 dollars, so $d=109/33=3+(10/33)$, and the formulas give 23 bananas at 3 dollars each, 10 bananas at 4 dollars each.2012-04-23