Hi all, I would like to ask the following qn:

In a computer, will

x / (a * b * c * d * e)

give a different solution from

x / a / b / c / d / e

where x,a,b,c,d,e are all integer data types? Since values are rounded down, I was wondering if that would cost the 2nd method of division to reach a smaller value than the 1st method if too much rounding is done.

Intuitively, it seems that it should not matter, but I cannot really prove it. Can someone help me out? Thanks!

In a computer, will

x / (a * b * c * d * e)

give a different solution from

x / a / b / c / d / e

where x,a,b,c,d,e are all integer data types? Since values are rounded down, I was wondering if that would cost the 2nd method of division to reach a smaller value than the 1st method if too much rounding is done.

Intuitively, it seems that it should not matter, but I cannot really prove it. Can someone help me out? Thanks!

Then x/a is (b*c*d*e)*q + [r/a], where [x] is rounding down of float value.

x/a/b is (c*d*e)*q + [[r/a]/b]

...

x/a/b/c/d/e is q+[[[[[r/a]/b]/c]/d]/e].

As r is strictly less than a*b*c*d*e, [[[[[r/a]/b]/c]/d]/e]=0.

a=b=c=d=e= 10^{9},a·b·c·d·eis really larger than maximal value ofint. So, result is undefinedUPD: it isn't correct in C/C++ (maybe Java), but correct in Python, because in C/C++ 3/(-2)=-1. Thanks to VladBelousThanks for your comments. Actually, what I was asking is whether

floor(x / (a * b * c * d * e))

in normal arithmetic is the same as

x / a / b / c / d / e

in computer arithmetic.

But you have still managed to answer my question. Thanks everyone! So unless I am dealing with negative numbers in Python, this should work fine.