0

My colleague ran into the following problem while writing billing software.

Suppose you have a monetary amount $M$ and a tax rate $t$. For example, $M = 20.1253$ and $t = 0.07$.

The question is what are the formulas for the numbers $L$ and $H$ such that $L$ $(H)$ is the lowest (highest) number with 2 decimal places such that $T(L) = T(M)$ and $T(H) = T(M)$ with $T(x)={1\over100}[100tx + 0.5]$ where $[]$ is the greatest integer function.

In other words, what is the formula, in terms of $M$ and $t$, of the lowest and highest monetary amounts which have the same tax amount as $M$, given tax rate $t$ and rounding to the nearest penny including rounding exact halves upwards?

Ross Millikan
  • 374,822
  • It should be tM for the taxes on M. Yes, round up on 0.005 always! –  Feb 02 '16 at 06:19
  • You round up on $0.005$? That seems what the government would specify. It would be better to write it as $t(L), t(M), t(H)$ because they are not strictly multiplications, it is a function. – Ross Millikan Feb 02 '16 at 06:22
  • They are products for this question. Oh okay I see what you mean. They are rounded products. –  Feb 02 '16 at 06:23
  • No, they are rounded versions of products. If they were really products, I could divide by $t$ and get $L=M=H$ – Ross Millikan Feb 02 '16 at 06:24
  • Ok, feel free to edit it to make it better. –  Feb 02 '16 at 06:31

1 Answers1

0

Given $T(M)=\frac 1{100}\lfloor 100tM+0.5\rfloor$ is the tax on $M$, we want to find $L$, the lowest price that results in $T$. We want the minimum $L$ such that $tL \ge T(M)-0.005$ or (assuming $L$ must be an exact number of cents) $L=\frac 1{100}\lceil \frac{100}t(T(M)-0.005)\rceil$. Similarly we want to find the maximum $H$ such that $tH \lt T(M)+0.005$, which is $H=\frac 1{100}\left(\lceil \frac{100}t (T(M)+0.005)\rceil-1\right)$ where the round up and $-1$ is to make sure we round $0.005$ downwards.

Ross Millikan
  • 374,822
  • Woah, thanks. We can assume L must be an exact monetary value. So we'd get the formula by substituting in the formula for T(M) from the beginning. Neat! Now I just have to figure out the steps in between. –  Feb 02 '16 at 06:54