diff options
author | Stig Bakken <ssb@php.net> | 2000-07-18 11:02:28 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2000-07-18 11:02:28 +0000 |
commit | 7bb67a620032ed679826b103e33282ea2126be70 (patch) | |
tree | b4b9812fd2e0bf37d156650654b75b2ebf52b799 /ext | |
parent | bb5987fe7410b2172bc2b96000432899fe1387aa (diff) | |
download | php-git-7bb67a620032ed679826b103e33282ea2126be70.tar.gz |
@Set default include_path so PEAR files can be reached (Stig)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/rand.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/standard/rand.c b/ext/standard/rand.c index 9766ecfcb3..0413e31269 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -262,16 +262,16 @@ PHP_FUNCTION(rand) return_value->value.lval = rand(); #endif #endif - /* - * A bit of tricky math here. We want to avoid using a modulus because - * that simply tosses the high-order bits and might skew the distribution - * of random values over the range. Instead we map the range directly. - * - * We need to map the range from 0...M evenly to the range a...b + /* + * A bit of tricky math here. We want to avoid using a modulus because + * that simply tosses the high-order bits and might skew the distribution + * of random values over the range. Instead we map the range directly. + * + * We need to map the range from 0...M evenly to the range a...b * Let n = the random number and n' = the mapped random number - * + * * Then we have: n' = a + n(b-a)/M - * + * * We have a problem here in that only n==M will get mapped to b which # means the chances of getting b is much much less than getting any of # the other values in the range. We can fix this by increasing our range @@ -279,7 +279,7 @@ PHP_FUNCTION(rand) # # n' = a + n(b-a+1)/M * - # Now we only have a problem if n==M which would cause us to produce a + # Now we only have a problem if n==M which would cause us to produce a # number of b+1 which would be bad. So we bump M up by one to make sure # this will never happen, and the final algorithm looks like this: # |