I have the function below as part of my program but I'm having some problems with it. To summarize what some of it means, rmaxed is a number produced by multiplying user entered probability by RAND_MAX, rando is just a random number that comes from an earlier generated index, d is another user entered probability, and t is an integer that has to do with a counter. The reversal index is just a way of recording if at any point the else block is activated. Now I have the problem that when rlik=0 and rando=0 the else function is engaged. Also it seems the else block is ONLY triggered when rando is SMALLER than rlik. For instance if rando=7 and rlik=9 the else block will run. Conversely when rando is larger than rlik the if statement runs.
The rest of the code in my program besides this function seems to be working perfectly but this is leaving me thoroughly confused. In another function of the program a <= test works perfectly fine.
Code:
int rev(int t, int index, int i) /*Regain sim*/
{
int rlik, rando; /*Probability of reversal, Random number from string*/
rlik=rmaxed*pow((1-d), (t-1));
rando=ran[ri];
ri++;
if(rando>rlik) return(0);
else {
reversal[index]=1;
return(1);
}
}
To put this more simply, the ">" is acting like a "<=" for no clear reason.