Numberick icon indicating copy to clipboard operation
Numberick copied to clipboard

Wrapping unsigned binary integer subtraction

Open oscbyspro opened this issue 2 years ago • 0 comments

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 avatar Nov 08 '23 17:11 oscbyspro