Closed Krym4s closed 7 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 94.00%. Comparing base (
3c5e5e0
) to head (d0c091f
).
Added new commit with shared library build fix. Also added some tests.
Thanks for the PR; I definitely should have had test coverage of this case. I think the extra codepath here is unnecessary though; if both sides are negative then we can fall through to the normal unsigned handling case, since negative numbers will compare correctly when both are negative and treated as unsigned. In fact I can probably clean up these comparison functions a bit more to make them more efficient anyway.
I'm not entirely convinced of the need for the getMinValue / getMaxValue functions added here. They seem unrelated to the bug? At the very least the overloads that accept another SVInt are confusing, since the value of that parameter doesn't contribute to the result.
Thank you for your answer. Yes, getMinValue and getMaxValue are not related to this bug, so it is better to remove it from this PR, but I think that this methods are useful, so maybe it is possible to add them later.
In new commit I handled case when only one of two signed numbers are negative. Also I added tests for this case. In case two values are negative we fall through to the normal unsigned handling case.
Thanks, lgtm
Hello, SVInt compares incorrectly with minimum signed int value. These test cases are failed on current main branch
It is because of negation of minimum signed int value is impossible (INT_MIN = -INT_MAX-1). This fact is used here. It is better to compare bit inversions of negative values as
so every value can be represented.
This patch also includes function for representing minimum and maximum integer values.