Skip to content

Commit 407995a

Browse files
felixrehrenStefanKarpinski
authored andcommitted
document x % T (#20759)
1 parent 9163e67 commit 407995a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

base/int.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,21 @@ for to in BitInteger_types, from in (BitInteger_types..., Bool)
359359
end
360360
end
361361

362+
"""
363+
rem(x::Integer, T<:Integer)
364+
mod(x::Integer, T<:Integer)
365+
%(x::Integer, T<:Integer)
366+
367+
Find `y::T` such that `x` ≡ `y` (mod n), where n is the number of integers representable
368+
in `T`, and `y` is an integer in `[typemin(T),typemax(T)]`.
369+
370+
```jldoctest
371+
julia> 129 % Int8
372+
-127
373+
```
374+
"""
375+
rem, mod
376+
362377
rem{T<:Integer}(x::T, ::Type{T}) = x
363378
rem(x::Integer, ::Type{Bool}) = ((x & 1) != 0)
364379
mod{T<:Integer}(x::Integer, ::Type{T}) = rem(x, T)

0 commit comments

Comments
 (0)