Skip to content

Commit

Permalink
srand: throw DomainError if a negative seed is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jan 5, 2013
1 parent 5a51622 commit 3c5946c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/rng.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ end
srand(n::Integer) = srand(make_seed(n))

function make_seed(n::Integer)
n < 0 && throw(DomainError())
seed = Uint32[]
while true
push(seed, n & 0xffffffff)
n >>= 32
if n == 0 || ~n == 0
if n == 0
return seed
end
end
Expand Down

0 comments on commit 3c5946c

Please sign in to comment.