Fix a bug. When using rand()<=p as condition, if p==0, this means every float number that is beyond machine's percison length are counted as it satisfies the condition, which, however,  is not correct.