Jump to content

[SOLVED] Percentage


Minase

Recommended Posts

Couldn't you just do:

 

<?php
$r = rand(0, 99);
$number = ($r < 2) ? 0 : 1;

 

 

There are 2 numbers less than 2 (0 and 1), therefore 2/100 = 2% chance.

There are 98 numbers not less (in other words, greater than or equal to) than 2, so there's a 98% chance of 1.

 

 

Or is this way not random enough or something?

Link to comment
https://forums.phpfreaks.com/topic/119872-solved-percentage/#findComment-617635
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.