You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solidity/random-datasource/randomExample.sol
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,8 @@ contract RandomExample is usingOraclize {
34
34
newRandomNumber_bytes(bytes(_result)); // this is the resulting random number (bytes)
35
35
36
36
// for simplicity of use, let's also convert the random bytes to uint if we need
37
-
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
38
-
uint randomNumber =uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange] range
37
+
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
38
+
uint randomNumber =uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange-1] range
39
39
40
40
newRandomNumber_uint(randomNumber); // this is the resulting random number (uint)
0 commit comments