oscbyspro / Ultimathnum

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

Super generic init(clamping:) #21

Closed oscbyspro closed 2 weeks ago

oscbyspro commented 2 weeks ago

EdgyInteger is an unusual constraint so it might be nice to add init(clamping:):

Self Source Result Status
EdgyInteger BinaryInteger Self X
BinaryInteger FiniteInteger Self
BinaryInteger BinaryInteger Optional\<Self>

I have only thought about if briefly, but the above cases should be derivable.

oscbyspro commented 2 weeks ago

The nil case would be IXL(clamping: UXL.max), or similar, in the most generic context.

oscbyspro commented 2 weeks ago

One nice thing about this is that I can just add init(clamping:) to Test.exactly(_:_:).

oscbyspro commented 2 weeks ago

Looks like I8(clamping: UXL.max) returns nil. Gotta fix that too. Zzz.

oscbyspro commented 2 weeks ago

The most generic init(clamping:) also needs to be a disfavored overload, it seems.