Closed 0x5844 closed 2 months ago
Thanks for this! You know the current team-size, so we really appreciate these PR's 😄
--
I've made a few changes, most notably, I've removed the exception throwing after a discussion with Erwan:
Throwing exceptions means you rely on the code around that to be set up for that, which it currently is not. If we only want to know where it crashed, then we can just rely on SIGFPE to be signalled on division-by-zero (which is almost the only case where FPE happens anyway).
If we want to use exceptions in the code in general, we should have that discussion, but introducing this into a PR that fixes other stuff is not a good idea (especially in the same commit). -- Even then I'm on the fence on these particular functions, which should be basic math-ops.
That sounds great! I was on the fence about throwing exceptions but I went forward with it. I updated the tests under https://github.com/Ultimaker/CuraEngine/pull/2135/commits/953714c469fba494f6e21df85cb77f734560b4d6 and removed the exception expectation from them.
That sounds great! I was on the fence about throwing exceptions but I went forward with it.
That's what we have reviews for!
Dumping some info here since I'm off until next Tuesday:
Dumping some info here since I'm off until next Tuesday:
Let me know if I can help with anything!
Description
This pull request addresses a critical issue in the
math.h
utility functions related to incorrect rounding behavior in theceil_divide_signed
function. Specifically, it fixes a bug where the function would incorrectly round up even when the division was exact, such as returning31
instead of30
forceil_divide_signed(90, 3)
-> (https://github.com/Ultimaker/CuraEngine/issues/2005)Additionally, the PR includes the following improvements:
round_divide_signed
andfloor_divide_signed
to clarify logic, improve readability, and maintain consistency.Type of change
How Has This Been Tested?
Test Configuration:
Checklist: