AliceVision icon indicating copy to clipboard operation
AliceVision copied to clipboard

Fix wrong integer division where rounding up was intended

Open p12tic opened this issue 1 year ago • 0 comments

The intention in cases like std::ceil(a / b) (where a and b are integers) likely was to get floating-point division result and round it upwards. However, the division was performed with integer arguments, fractional part was lost and thus std::ceil did nothing. This PR introduces a separate function to perform such integer division and fixes the buggy cases.

If the original intention was wrong, this PR will break behavior. According to my limited understanding of the code the original intention was correct.

A subsequent PR will change all similar cases where we currently do int(std::ceil(double(a) / double(b))) to use divideRoundUp().

p12tic avatar Oct 02 '22 00:10 p12tic