Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping unsigned binary integer subtraction #110

Open
oscbyspro opened this issue Nov 8, 2023 · 0 comments
Open

Wrapping unsigned binary integer subtraction #110

oscbyspro opened this issue Nov 8, 2023 · 0 comments
Labels
addition oh, so shiny! maybe to do, or not to do?

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Nov 8, 2023

NBKUnsignedInteger already requires recoverable unsigned subtraction (#34):

func subtractingReportingOverflow(_ other: Self) -> PVO<Self>
mutating func subtractReportingOverflow(_ other: Self) -> Bool

@_disfavoredOverload func subtractingReportingOverflow(_ other: Digit) -> PVO<Self>
@_disfavoredOverload mutating func subtractReportingOverflow(_ other: Digit) -> Bool

These have well-defined 2's complement semantics. How about conveniences?

static func &- (lhs:       Self, rhs: Self) -> Self
static func &-=(lhs: inout Self, rhs: Self)

@_disfavoredOverload static func &- (lhs:       Self, rhs: Digit) -> Self 
@_disfavoredOverload static func &-=(lhs: inout Self, rhs: Digit)
@oscbyspro oscbyspro added addition oh, so shiny! maybe to do, or not to do? labels Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny! maybe to do, or not to do?
Projects
None yet
Development

No branches or pull requests

1 participant