Add UInt24 readonly struct with .NET 10 generic math interfaces#2
Add UInt24 readonly struct with .NET 10 generic math interfaces#2Copilot wants to merge 7 commits into
Conversation
Implements IBinaryInteger<UInt24>, IMinMaxValue<UInt24>, and IUnsignedNumber<UInt24> with all required sub-interfaces including arithmetic, comparison, bitwise, shift, parsing, formatting, and conversion operators. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cast int literals to UInt24 in SetUInt24/WriteUInt24/AddUInt24 calls. Cast UInt24 results to int before Should().Equal() assertions. Fix overflow value 0x78654321 to valid UInt24 value 0x654321. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover constants, equality, comparison, arithmetic (checked/unchecked), bitwise/shift operators, conversion operators, formatting, parsing, INumber, IBinaryNumber, IBinaryInteger, and INumberBase methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| var result = left._value + right._value; | ||
| if (result > MaxValueUInt32) | ||
| { | ||
| throw new OverflowException(); |
There was a problem hiding this comment.
Can you give useful messages every time you throw an OverflowException please?
There was a problem hiding this comment.
Added descriptive messages to all 11 OverflowException throws — arithmetic operators get specific messages like "UInt24 addition overflowed.", and conversion/construction paths get "Value was either too large or too small for a UInt24.". Done in cac4c14.
There was a problem hiding this comment.
Can you add even more descriptive messages? E.g. include something like 16000000 + 2000000 = 18000000 which overflowed the maximum value of 16777216. @copilot
There was a problem hiding this comment.
Updated all 11 OverflowException messages to include the actual operand values and results. For example:
- Addition:
"16000000 + 2000000 = 18000000 which exceeds the maximum UInt24 value of 16777215." - Subtraction:
"5 - 10 would result in a negative value which is outside the range of a UInt24." - Conversions:
"The value 20000000 is outside the range of a UInt24 (0 to 16777215)."
Done in cd627ae.
Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
MrKWatkins
left a comment
There was a problem hiding this comment.
Can you add even more descriptive overlflow messages? E.g. include something like 16000000 + 2000000 = 18000000 which overflowed the maximum value of 16777216.
Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Done in cd627ae — all overflow messages now include the actual values involved in the operation. |
UInt24readonly struct with generic math interfacesUInt24type💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.