Closed oscbyspro closed 3 weeks ago
ArbitraryInteger & SignedInteger
multiplication is never lossy:
extension BinaryInteger where Self: ArbitraryInteger & SignedInteger {
func squared() -> Self
func times(_ other: Self) -> Self
}
ArbitraryInteger & SignedInteger
addition is never lossy:
extension BinaryInteger where Self: ArbitraryInteger & SignedInteger {
mutating func negate()
func negated() -> Self
func plus (_ other: Self) -> Self
func minus(_ other: Self) -> Self
func incremented(_ condition: Bool = true) -> Self
func decremented(_ condition: Bool = true) -> Self
}
ArbitraryInteger & SignedInteger
factorial is never lossy:
extension BinaryInteger where Self: ArbitraryInteger & SignedInteger {
func factorial() -> Optional<Self>
}
Now that the most generic division result is optional (#69) (#95), it makes sense to add conveniences mapping division by zero to
nil
. Additionally, I can add non-optional and non-fallible conveniences in theArbitraryInteger & SignedInteger
(lenient) case like I've already done in theSystemsInteger & UnsignedInteger
(natural) case.