1

This may seem a simple stupid question but its driving me crazy for 4 hours.

I have two values $-10.5$ and $+15.0$

These values sum $4.5$. For whatever reason that doesn't matter the end result must be floored. The final value in this case must be $4$.

The $0.5$ difference must be distributed on the first two values.

What is the mathematical equation to apply to the first two values for they to sum $4$?

Daniel
  • 11
  • 1
    So you have to diminish both together by 0.5. That can obviously be done in many ways, but the engineer in me says split equally, i.e., make them -10.75 and +15.25. – vonbrand Mar 11 '14 at 23:59
  • @Vonbrand, it's the equal splitting algorithm that I'm looking for. Its not impossible. I know a way it can work but I don't understand why it works. The first solution is to calculate the weight of each number in the unfloored sum. This gives the percentage that each value contributes to the final unfloored result. Then you multiply that percentage with the floored result and the two values are distributed. This approach seems alright but it isn't because you analyse the results the two values changed but the variation is way high. –  Mar 12 '14 at 01:14
  • The second solution that I have is to sum the absolute values and calculate the weight of each absolute value in the sum of the absolute values. This also gives a percentage that if you multiply by the floored result will give a better distribution. I understand my first solution but I don't like it because the variations are too high. The second solution seems to be my answer but I don't understand how it works. I'm summing different values than the originals. The negatives are turned into positives but somehow this works. –  Mar 12 '14 at 01:14

1 Answers1

1

In this particular case you can just floor the two values: $\lfloor-10.5\rfloor+\lfloor15.0\rfloor=-11+15=4$.

This doesn't work in general though, since $$\lfloor-10.5\rfloor+\lfloor14.5\rfloor=-11+14=3\ne\lfloor-10.5+14.5\rfloor=4.$$

Let's try to find a function $f$ such that $\lfloor a+b\rfloor=f(a)+f(b)$. Setting $a=b=0$ gives $$0=\lfloor 0+0\rfloor=f(0)+f(0)=2f(0)\implies f(0)=0.$$ Now we can set $b=0$ while letting $a$ be any number. This gives $f(a)=\lfloor a\rfloor$, which we already concluded did not work in general. Thus it is impossible to find a function that works in the general case.