Generate a random number which is greater than a specific number?

The problem probably comes from overflow. Let say your prng generate a number between 0 and maxint. If you simply add the floor, what occur when the addition gives a number greater than maxint?

Of course, you could simply reject those numbers, but it would result in the same algorithm as the one you proposed.

$RANDOM won't ever have a result greater than 32767. However, if you're expecting a result between $FLOOR and 32767, adding $FLOOR and $RANDOM won't help you. If you treat any value greater than 32767 as 32767 then you're making your generator more predictable.

Not quite as bad is modding your result by (32767 - $FLOOR) and adding $FLOOR. Another solution without looping is to use $RANDOM * ( 32767 - $FLOOR ) / 32767 + $FLOOR but bash lacks floating point math and may miss a couple numbers due to rounding error.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions