bash - Why do I not see the full expected range of random numbers? -


this question has answer here:

i expect below code generate (quasi) random numbers between 0.9 , 1.0 rh.

randno5=$((random % 100001)) upper_limit5=$(echo "scale=10; 1*1.0"|bc) lower_limit5=$(echo "scale=10; 1*0.9"|bc) range5=$(echo "scale=10; $upper_limit5-$lower_limit5"|bc) rh=`echo "scale=10; ${lower_limit5}+${range5}*${randno5}/100001" |bc` 

however, when run code value between 0.9 , 0.933(3sf). why case?

$random is, @ most, 32767:

   random each time parameter referenced, random integer between           0 , 32767 generated.  sequence of random numbers may           initialized assigning value random.  if random unset,            loses   special  properties,  if subsequently           reset. 

your modulus have no effect generated numbers restricted range.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -