Skip to content

Commit

Permalink
correct wrong range in some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Persiani committed Nov 9, 2018
1 parent 8e358b1 commit 47f5242
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions solidity/random-datasource/randomExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ contract RandomExample is usingOraclize {
newRandomNumber_bytes(bytes(_result)); // this is the resulting random number (bytes)

// for simplicity of use, let's also convert the random bytes to uint if we need
uint maxRange = 2**(8* 7); // this is the highest uint we want to get. It should never be greater than 2^(8*N), where N is the number of random bytes we had asked the datasource to return
uint randomNumber = uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange] range
uint maxRange = 2**(8* 7); // [maxRange - 1] is the highest uint we want to get.The variable maxRange should never be greater than 2^(8*N), where N is the number of random bytes we had asked the datasource to return
uint randomNumber = uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange-1] range

newRandomNumber_uint(randomNumber); // this is the resulting random number (uint)
}
Expand Down

0 comments on commit 47f5242

Please sign in to comment.