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

Add: Division/exactly() #70

Closed
oscbyspro opened this issue Aug 21, 2024 · 0 comments
Closed

Add: Division/exactly() #70

oscbyspro opened this issue Aug 21, 2024 · 0 comments
Labels
addition oh, so shiny!

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Aug 21, 2024

The following is super convenient when you need to ensure lossless behavior (#67).

extension Division where Quotient: BinaryInteger, Remainder: BinaryInteger {
    /// Returns the `quotient` and an `error` indicator.
    ///
    /// The `error` is set when the `remainder` is nonzero.
    ///
    @inlinable public consuming func exactly() -> Fallible<Quotient> {
        self.quotient.veto(!self.remainder.isZero)
    }
}
@oscbyspro oscbyspro added the addition oh, so shiny! label Aug 21, 2024
@oscbyspro oscbyspro added this to the Ultimathnum 0.9.0 milestone Aug 21, 2024
oscbyspro added a commit that referenced this issue Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny!
Projects
None yet
Development

No branches or pull requests

1 participant