From: Gurusamy Sarathy Date: Mon, 26 Oct 1998 00:50:02 +0000 (+0000) Subject: sanity-check $Config{drand01} in rand.t X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce9935e078582f01b05cad6db77c0a8312bee15b;p=p5sagit%2Fp5-mst-13.2.git sanity-check $Config{drand01} in rand.t p4raw-id: //depot/perl@2085 --- diff --git a/t/op/rand.t b/t/op/rand.t index a68559f..2f02d34 100755 --- a/t/op/rand.t +++ b/t/op/rand.t @@ -52,6 +52,17 @@ sub bits ($) { $max = $min = rand(1); for (1..$reps) { my $n = rand(1); + if ($n < 0.0 or $n >= 1.0) { + print <= 1.0. +# Make sure \$Config{drand01} is a valid expression in the +# C-language, and produces values in the range [0.0,1.0). +# +# I give up. +EOM + exit; + } $sum += $n; $bits += bits($n * 256); # Don't be greedy; 8 is enough # It's too many if randbits is less than 8! @@ -75,7 +86,7 @@ sub bits ($) { # wrong value is that Config.pm is incorrect.) # if ($max <= 0 or $max >= (2 ** $randbits)) {# Just in case... - print "not ok 1\n"; + print "# max=[$max] min=[$min]\nnot ok 1\n"; print "# This perl was compiled with randbits=$randbits\n"; print "# which is _way_ off. Or maybe your system rand is broken,\n"; print "# or your C compiler can't multiply, or maybe Martians\n"; @@ -91,7 +102,7 @@ sub bits ($) { $off = int($off) + ($off > 0); # Next more positive int if ($off) { $shouldbe = $Config{randbits} + $off; - print "not ok 1\n"; + print "# max=[$max] min=[$min]\nnot ok 1\n"; print "# This perl was compiled with randbits=$randbits on $^O.\n"; print "# Consider using randbits=$shouldbe instead.\n"; # And skip the remaining tests; they would be pointless now. diff --git a/win32/config.bc b/win32/config.bc index 7f27132..69620ab 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -331,7 +331,7 @@ direntrytype='struct direct' dlext='dll' dlsrc='dl_win32.xs' doublesize='8' -drand01='rand()' +drand01='(rand()/(double)((unsigned)1<