oscbyspro / Ultimathnum

Binary arithmetic reimagined in Swift
Apache License 2.0
4 stars 1 forks source link

Generic shift operations #32

Closed oscbyspro closed 17 hours ago

oscbyspro commented 1 week ago

I'll add generic shift operations with appropriate paths to the Shift\<T> base implementation:

static func  <<=(instance: inout     Self, distance: some BinaryInteger)
static func  << (instance: consuming Self, distance: some BinaryInteger) -> Self 
static func  >>=(instance: inout     Self, distance: some BinaryInteger)
static func  >> (instance: consuming Self, distance: some BinaryInteger) -> Self

static func &<<=(instance: inout     Self, distance: some BinaryInteger)
static func &<< (instance: consuming Self, distance: some BinaryInteger) -> Self 
static func &>>=(instance: inout     Self, distance: some BinaryInteger)
static func &>> (instance: consuming Self, distance: some BinaryInteger) -> Self
oscbyspro commented 1 week ago

I found the lack of generic shifts annoying when I prototyped (#25).

oscbyspro commented 1 week ago

I'll also unify Shift\<T> and Shift\<T.Magnitude> as the latter.

oscbyspro commented 17 hours ago

It also accepts Swift.Int distances because I needed to disambiguate integer literals...