View Single Post
  #8  
Old 12-20-2012, 01:48 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Those are some of the most weirdly complicated ways of doing this I've seen.

PHP Code:
function pickRandomNumber() {
  if (
random(01) < 0.5) {
    return 
5;
  } else {
    return 
10;
  }

Usually the simplest solution is best. Code readability > tricky math. It's a lot easier to look at mine and see what it does than it is to stop and mentally parse out int(random(1,2.9))*5.
__________________
Reply With Quote