Hi,
Im a C Sharp Developer mainly, and am converting some C++ code into C Sharp but have come across a line of code that has totally thrown me and I can work out what is it doing. The line is as follows.
define RANDCHANCE(a) ((((float)rand()) + 0.5)*(1.0/(float)RAND_MAX)
<= a)
Now im not totally stupid. I know its creating a random number that is a float. Im guessing RAND_MAX is a C++ system varible, but thats not the main issue. I am confused by the RANDCHANCE(a) and <= a at the end. a is never assigned anywhere in the code.
Any help would be great.
Thanks for you time.
Regards
James
Start Free Trial