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

Composition with SaferIntegers.jl #22

Closed
mkitti opened this issue Sep 1, 2021 · 2 comments
Closed

Composition with SaferIntegers.jl #22

mkitti opened this issue Sep 1, 2021 · 2 comments

Comments

@mkitti
Copy link

mkitti commented Sep 1, 2021

SimpleRatio would benefit from overflow protection via SaferIntegers.jl.

The main issue I see at the moment is that SafeSigned and SafeUnsigned have SafeInteger as a supertype rather than Signed and Unsigned:

julia> supertype(SafeSigned)
SafeInteger

julia> supertype(SafeUnsigned)
SafeInteger

julia> using Ratios, SaferIntegers

julia> -SimpleRatio(SafeInt(3), SafeInt(5))
ERROR: MethodError: no method matching -(::SimpleRatio{SafeInt64})

Thus we would need this method via Requires.jl:

Base.:-(x::SimpleRatio{T}) where {T<:SafeSigned} = SimpleRatio(-x.num, x.den)
@mkitti
Copy link
Author

mkitti commented Sep 1, 2021

x.f. JuliaMath/Interpolations.jl#457

@mkitti
Copy link
Author

mkitti commented Sep 15, 2021

Closed by JeffreySarnoff/SaferIntegers.jl#20 and subsequent ambiguity pull requests.

@mkitti mkitti closed this as completed Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant