Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 26, 2013
2 parents 678028f + 8818797 commit c4f0e20
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ rand(::Type{Int32}) = int32(rand(Uint32)) & typemax(Int32)
rand(::Type{Int64}) = int64(rand(Uint64)) & typemax(Int64)
rand(::Type{Int128}) = int128(rand(Uint128)) & typemax(Int128)

for itype in (:Uint32, :Uint64, :Uint128, :Int32, :Int64, :Int128)
@eval begin
function rand!(A::Array{$itype})
for i=1:length(A)
A[i] = rand($itype)
end
A
end
rand(::Type{$itype}, dims::Dims) = rand!(Array($itype, dims))
rand(::Type{$itype}, dims::Int...) = rand($itype, dims)
end
end

# random integer from lo to hi inclusive
function rand{T<:Integer}(r::Range1{T})
lo = r[1]
Expand Down

0 comments on commit c4f0e20

Please sign in to comment.