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

DivideError in mutability(T, div, T, T), where T == Rational{BigInt} #240

Open
nsajko opened this issue Nov 26, 2023 · 1 comment
Open

Comments

@nsajko
Copy link
Contributor

nsajko commented Nov 26, 2023

julia> import MutableArithmetics

julia> f(op::F, ::Type{T}) where {F, T} = MutableArithmetics.mutability(T, op, T, T)
f (generic function with 1 method)

julia> f(/, BigInt)
MutableArithmetics.IsNotMutable()

julia> f(div, BigInt)
MutableArithmetics.IsMutable()

julia> f(/, Rational{BigInt})
MutableArithmetics.IsMutable()

julia> f(div, Rational{BigInt})
ERROR: DivideError: integer division error
Stacktrace:
  [1] tdiv_q!(x::BigInt, a::BigInt, b::BigInt)
    @ Base.GMP.MPZ ./gmp.jl:165
  [2] tdiv_q
    @ ./gmp.jl:166 [inlined]
  [3] div
    @ ./gmp.jl:508 [inlined]
  [4] div
    @ ./gmp.jl:512 [inlined]
  [5] divgcd(x::BigInt, y::BigInt)
    @ Base ./rational.jl:43
  [6] div(x::Rational{BigInt}, y::Rational{BigInt}, r::RoundingMode{:ToZero})
    @ Base ./rational.jl:481
  [7] div
    @ Base ./rational.jl:488 [inlined]
  [8] div
    @ Base ./rational.jl:492 [inlined]
  [9] promote_operation_fallback
    @ MutableArithmetics ~/tmp/jl/MutableArithmetics.jl/src/interface.jl:51 [inlined]
 [10] promote_operation
    @ MutableArithmetics ~/tmp/jl/MutableArithmetics.jl/src/interface.jl:113 [inlined]
 [11] mutability
    @ MutableArithmetics ~/tmp/jl/MutableArithmetics.jl/src/interface.jl:266 [inlined]
 [12] f(op::typeof(div), ::Type{Rational{BigInt}})
    @ Main ./REPL[2]:1
 [13] top-level scope
    @ REPL[6]:1

(@v1.11) pkg> st MutableArithmetics
Status `~/.julia/environments/v1.11/Project.toml`
  [d8a4904e] MutableArithmetics v1.3.3 `~/tmp/jl/MutableArithmetics.jl`
@blegat
Copy link
Member

blegat commented Nov 30, 2023

It's just missing a promote_operation method it seems. By the way if you're interested in rational mutable arithmetics, there is a WIP PR in #141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants