Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use crypto:rand_uniform and removed -1
Since crypto:rand_uniform returns N, with Lo <= N < Hi, we don't need -1 here.
  • Loading branch information
luuhq committed Mar 29, 2013
commit 9230dcb58aaceb0acb67b84531a69f5c3668b965
8 changes: 4 additions & 4 deletions uuid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

% Generates a random binary UUID.
v4() ->
v4(random:uniform(1 bsl 48) - 1,
random:uniform(1 bsl 12) - 1,
random:uniform(1 bsl 32) - 1,
random:uniform(1 bsl 30) - 1).
v4(crypto:rand_uniform(1 bsl 48),
crypto:rand_uniform(1 bsl 12),
crypto:rand_uniform(1 bsl 32),
crypto:rand_uniform(1 bsl 30)).

v4(R1, R2, R3, R4) ->
<<R1:48, 4:4, R2:12, 2:2, R3:32, R4: 30>>.
Expand Down