• Advertisement

Archived

This topic is now archived and is closed to further replies.

help: rand() crashes

This topic is 5558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys, i have a problem with rand(). I wrote a small software programm to demostrate / test it: int main(int argc, char* argv[]){ for (int i=0;i<1000;i++){ for (int i2=0;i2<1000;i2++){ float r = rand(); float q = rand() +1; float t= r/q; int f = rand() % ((int) t); } } } well, my visual c .net compiler says, that there is a division by zero. but where and why??

Share this post


Link to post
Share on other sites
Advertisement
thanks. i misplaced a bracket in my original code:
now ist works

y += rand() %( ((int) (delta)) +1 ) ;

Share this post


Link to post
Share on other sites

  • Advertisement