$urandom generates unsigned values. Consider the following;
-
int a1;
a1 = $urandom;
//generates both positive and negative numbers. -
int unsigned a2;
a2 = $urandom;
//generates only positive numbers. -
int unsigned a3;
a3 = $random;
//generates only positive numbers with ‘$random’ keyword and not ‘$urandom’.
So, in order to generate positive numbers, explicit keyword ‘unsigned’ is required. This shows that there is no much difference between $random and $urandom.
In a simpler manner, without declaring the explicit keyword, we can still generate positive numbers;
- int a4;
a4 = $urandom_range(200,0);
//only positive numbers.
Can we make best practice of method 4) for simiplicity ?