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

Fix rem/mod doc #21223

Merged
merged 1 commit into from
Mar 29, 2017
Merged
Changes from all commits
Commits
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
32 changes: 18 additions & 14 deletions base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,24 @@ for to in BitInteger_types, from in (BitInteger_types..., Bool)
end
end

"""
rem(x::Integer, T::Type{<:Integer})
mod(x::Integer, T::Type{<:Integer})
%(x::Integer, T::Type{<:Integer})

Find `y::T` such that `x` ≡ `y` (mod n), where n is the number of integers representable
in `T`, and `y` is an integer in `[typemin(T),typemax(T)]`.

```jldoctest
julia> 129 % Int8
-127
```
"""
function rem(x::Integer, T::Type) end, function mod(x::Integer, T::Type) end
# @doc isn't available when running in Core at this point.
# Tuple syntax for documention two function signatures at the same time
# doesn't work either at this point.
isdefined(Main, :Base) && for fname in (:mod, :rem)
@eval @doc """
rem(x::Integer, T::Type{<:Integer})
mod(x::Integer, T::Type{<:Integer})
%(x::Integer, T::Type{<:Integer})

Find `y::T` such that `x` ≡ `y` (mod n), where n is the number of integers representable
in `T`, and `y` is an integer in `[typemin(T),typemax(T)]`.

```jldoctest
julia> 129 % Int8
-127
```
""" -> $fname(x::Integer, T::Type{<:Integer})
end

rem{T<:Integer}(x::T, ::Type{T}) = x
rem(x::Integer, ::Type{Bool}) = ((x & 1) != 0)
Expand Down