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

x % Unsigned, x % Signed #34864

Merged
merged 36 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6a35def
support `x % Unsigned` where `isa(x, Signed)`
JeffreySarnoff Feb 24, 2020
6b87b76
support `x % Unsigned` where `isa(x, Signed)`
JeffreySarnoff Feb 25, 2020
17f3c79
support `x % Unsigned` where `isa(x, Signed)`
JeffreySarnoff Feb 25, 2020
58f8708
`x % Unsigned` where `isa(x, Signed)` (remove comma)
JeffreySarnoff Feb 25, 2020
65367c5
`x::Signed % Unsigned, x::Unsigned % Signed`
JeffreySarnoff Feb 25, 2020
1a1b028
`rem(x::Unsigned, Signed)`
JeffreySarnoff Feb 25, 2020
bcaa805
`x::Unsigned % Signed`
JeffreySarnoff Feb 25, 2020
fb30b63
remove trailing space
JeffreySarnoff Feb 25, 2020
bfd416b
interconvert BitInteger pairs
JeffreySarnoff Feb 25, 2020
536948e
remove `unsigned(<:Signed)` lines, import `unsigned` from Base
JeffreySarnoff Feb 25, 2020
152d6e8
add tests, improve tests
JeffreySarnoff Feb 25, 2020
98204f5
news about `signed(T)`, `unsigned(T)`
JeffreySarnoff Feb 25, 2020
c1988c1
remove trailing whitespace
JeffreySarnoff Feb 25, 2020
61e2362
fix test
JeffreySarnoff Feb 25, 2020
3fbcf18
fix missing `begin`
JeffreySarnoff Feb 25, 2020
a1da6f4
add missing end
JeffreySarnoff Feb 25, 2020
8542442
revise tests
JeffreySarnoff Feb 25, 2020
9172d4d
fixup typo in test
JeffreySarnoff Feb 25, 2020
612b19d
restore multinverses.jl
JeffreySarnoff Feb 29, 2020
53ec10b
remove `unsigned(::Type{BitSigned})` (was available). add `signed(::…
JeffreySarnoff Feb 29, 2020
3371f21
add tests `BigInt(x) % Signed` `BigInt(x) % Unsigned`
JeffreySarnoff Feb 29, 2020
0518e73
resolve conflict?
JeffreySarnoff Feb 29, 2020
a8d2684
Merge branch 'master' into jas/remUnsigned
JeffreySarnoff Feb 29, 2020
e16cffb
add back what was a merge conflict in News
JeffreySarnoff Feb 29, 2020
a67e742
Update NEWS.md
JeffreySarnoff Mar 3, 2020
cd61928
Merge branch 'master' into jas/remUnsigned
JeffreySarnoff Mar 5, 2020
ecb9966
remove `signed(UIntNN) = IntNN` (does it fix?)
JeffreySarnoff Mar 14, 2020
3cbbec4
remove `signed(UIntNN) == IntNN` tests (does it fix?)
JeffreySarnoff Mar 14, 2020
574d8a6
restore `signed(::Type{UIntNN}) = IntNN`
JeffreySarnoff Mar 14, 2020
100884e
restore `signed(::Type{UIntNN}) = IntNN` tests
JeffreySarnoff Mar 14, 2020
cf1954a
whitespace
JeffreySarnoff Mar 14, 2020
03891ac
Merge branch 'master' into jas/remUnsigned
JeffreySarnoff Mar 27, 2020
6dc7fab
remove old line
JeffreySarnoff Mar 27, 2020
9c2befc
combine 3 testsets
JeffreySarnoff Mar 27, 2020
7b00bd5
docstrings for signed(T) unsigned(T)
JeffreySarnoff Mar 27, 2020
f46360a
move docstring up
JeffreySarnoff Mar 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ New library features

* `isapprox` (or `≈`) now has a one-argument "curried" method `isapprox(x)` which returns a function, like `isequal` (or `==`)` ([#32305]).
* `Ref{NTuple{N,T}}` can be passed to `Ptr{T}`/`Ref{T}` `ccall` signatures ([#34199])

* `x % Unsigned` now works where `typeof(x) :< Signed`.

Standard library changes
------------------------
Expand Down
1 change: 1 addition & 0 deletions base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ if nameof(@__MODULE__) === :Base
end

rem(x::T, ::Type{T}) where {T<:Integer} = x
rem(x::Signed, ::Type{Unsigned}) = x % unsigned(typeof(x))
Copy link
Member

Choose a reason for hiding this comment

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

Should probably also have the opposite x % Signed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done and tests are also done

rem(x::Integer, T::Type{<:Integer}) = convert(T, x) # `x % T` falls back to `convert`
rem(x::Integer, ::Type{Bool}) = ((x & 1) != 0)
mod(x::Integer, ::Type{T}) where {T<:Integer} = rem(x, T)
Expand Down