Can someone remind me of something. I always have trouble remembering this for some reason. If I have a 50% chance of something happening and I am using a random number, is the check < or <= in the following (< 0.5 (random))
Doh. That should be the other way around anyway (< (random) 0.5)
Either (< 0.5 (random))
or (< (random) 0.5)
should work. The doc for random
says “returns a random inexact number between 0 and 1, exclusive”, so neither 0.0 nor 1.0 are ever returned, so 0.5 is the exact middle point, and should be discarded. So no matter what order you choose, <
is strictly speaking the correct operator to use.
In practice, I don’t think <
or <=
would make any significant difference.
@diego Thanks, I realise it won’t make much of a difference, just wondered which was ‘right’. Thanks again.