Skip to content

Commit

Permalink
make MultiplicativeInverse<:Number (#48708)
Browse files Browse the repository at this point in the history
* make `MultiplicativeInverse<:Number`

This makes operations like `divrem.(3, Base.MultiplicativeInverses.multiplicativeinverse(3))` work.
  • Loading branch information
oscardssmith committed Feb 24, 2023
1 parent b5482c8 commit f0eadd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/multinverses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ unsigned(::Type{Int64}) = UInt64
unsigned(::Type{Int128}) = UInt128
unsigned(::Type{T}) where {T<:Unsigned} = T

abstract type MultiplicativeInverse{T} end
abstract type MultiplicativeInverse{T} <: Number end

# Computes integer division by a constant using multiply, add, and bitshift.

Expand Down
2 changes: 2 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,8 @@ Base.abs(x::TestNumber) = TestNumber(abs(x.inner))
@test_throws ArgumentError Base.multiplicativeinverse(0)
testmi(map(UInt32, 0:1000), map(UInt32, 1:100))
testmi(typemax(UInt32)-UInt32(1000):typemax(UInt32), map(UInt32, 1:100))
# test broadcasting works.
@test div.(3, Base.multiplicativeinverse(3)) == 1
end
@testset "ndims/indices/size/length" begin
@test ndims(1) == 0
Expand Down

4 comments on commit f0eadd0

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected.
A full report can be found here.

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected.
A full report can be found here.

Please sign in to comment.