diff options
| author | bors <bors@rust-lang.org> | 2024-10-27 10:42:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-27 10:42:36 +0000 |
| commit | 9fa0146c4a12ace3a23555b22797868a98128a37 (patch) | |
| tree | cce12c0fae63b4fdbb40066d02a242bb3c56146e /compiler/rustc_pattern_analysis/src/rustc.rs | |
| parent | e454c45f1397e382cfb59f0b8970445c8efa875f (diff) | |
| parent | 74b9de4af2c1200a82bfa9193423cc7889ddc924 (diff) | |
| download | rust-9fa0146c4a12ace3a23555b22797868a98128a37.tar.gz rust-9fa0146c4a12ace3a23555b22797868a98128a37.zip | |
Auto merge of #132191 - Urgau:midpoint_signed_towards_zero, r=dtolnay
Round negative signed integer towards zero in `iN::midpoint` This PR changes the implementation of `iN::midpoint` (the signed variants) to round negative signed integers **towards zero** *instead* of negative infinity as is currently the case. This is done so that the obvious expectations[^1] of `midpoint(a, b) == midpoint(b, a)` and `midpoint(-a, -b) == -midpoint(a, b)` are true, which makes the even more obvious implementation `(a + b) / 2` always true. The unsigned variants `uN::midpoint` (which are being [FCP-ed](https://github.com/rust-lang/rust/pull/131784#issuecomment-2417188117)) already rounds towards zero, so there is no consistency issue. cc `@scottmcm` r? `@dtolnay` [^1]: https://github.com/rust-lang/rust/issues/110840#issuecomment-2336753931
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/rustc.rs')
0 files changed, 0 insertions, 0 deletions
