LibMath - roundHalfUp returns unfinished result
The method `LibMathSigned.roundHalfUp(int `x`, int y)` returns the value `x` rounded up to the base `y`. The method suggests that the result is the rounded value while that's not actually true. The result for a positive `x` is `x` + base/2 and `x` - base/2 for negative values. The rounding is not yet finished as this would require a final division by base `y` to manifest the rounding.\\nIt is assumed that the final rounding step is not executed for performance reasons. However, this might easily introduce errors when the caller assumes the result is rounded for base while it is not.\\n`roundHalfUp(-4700, 1000) = -4700` instead of `5000`\\n`roundHalfUp(4700, 1000) = 4700` instead of `5000`\\n```\\n// ROUND\\_HALF\\_UP rule helper. 0.5 ≈ 1, 0.4 ≈ 0, -0.5 ≈ -1, -0.4 ≈ 0\\nfunction roundHalfUp(int256 x, int256 y) internal pure returns (int256) {\\n    require(y > 0, "roundHalfUp only supports y > 0");\\n    if (x >= 0) {\\n        return add(x, y / 2);\\n    }\\n    return sub(x, y / 2);\\n}\\n```\\n
We have verified the current code-base and the callers for `roundHalfUp` are correctly finishing the rounding step. However, it is recommended to finish the rounding within the method or document this behavior to prevent errors caused by code that falsely assumes that the returned value finished rounding.
```\\n// ROUND\\_HALF\\_UP rule helper. 0.5 ≈ 1, 0.4 ≈ 0, -0.5 ≈ -1, -0.4 ≈ 0\\nfunction roundHalfUp(int256 x, int256 y) internal pure returns (int256) {\\n    require(y > 0, "roundHalfUp only supports y > 0");\\n    if (x >= 0) {\\n        return add(x, y / 2);\\n    }\\n    return sub(x, y / 2);\\n}\\n```\\n