Bug 24083 – Int128.opCmp's behavior with negative numbers is inconsistent with Int128.opEquals

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-08-11T22:21:58Z
Last change time
2023-08-20T17:39:38Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2023-08-11T22:21:58Z
--- void main() { import std.stdio; import std.int128; writeln(Int128(-1L) == -1L); // writes true writeln(Int128(-1L) < -1L); // also writes true !!! } ---
Comment #1 by dlang-bot — 2023-08-11T22:43:48Z
@n8sh created dlang/phobos pull request #8798 "Fix Issue 24083 - Int128.opCmp's behavior with negative numbers is inconsistent with Int128.opEquals" fixing this issue: - Fix Issue 24083 - Int128.opCmp's behavior with negative numbers is inconsistent with Int128.opEquals Needed to make opCmp a template to avoid causing `Int128(-1L) < ulong.max` to return the wrong value or causing the compiler to complain that it can't determine which overload to call for `Int128(1) > 10`. https://github.com/dlang/phobos/pull/8798
Comment #2 by dlang-bot — 2023-08-20T17:39:38Z
dlang/phobos pull request #8798 "Fix Issue 24083 - Int128.opCmp's behavior with negative numbers is inconsistent with Int128.opEquals" was merged into stable: - dcdb02cb6caf1ba8d9dc083f85368bc47aed96c2 by Nathan Sashihara: Fix Issue 24083 - Int128.opCmp's behavior with negative numbers is inconsistent with Int128.opEquals https://github.com/dlang/phobos/pull/8798