path: root/mcon/U/randbits.U
diff options
authorManoj Srivastava <>2003-12-01 17:11:15 +0000
committerManoj Srivastava <>2003-12-01 17:11:15 +0000
commit371472d9fb6a936149b105a6563a0550d35bdf1a (patch)
tree6d23751e44a7dddf4e29918551f1ea0513352622 /mcon/U/randbits.U
Initial import of upstream branch
Initial import of upstream branch git-archimport-id:
Diffstat (limited to 'mcon/U/randbits.U')
1 files changed, 83 insertions, 0 deletions
diff --git a/mcon/U/randbits.U b/mcon/U/randbits.U
new file mode 100644
index 0000000..fb7be43
--- /dev/null
+++ b/mcon/U/randbits.U
@@ -0,0 +1,83 @@
+?RCS: $Id: randbits.U,v 1997/02/28 16:19:29 ram Exp $
+?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 3.0.
+?RCS: $Log: randbits.U,v $
+?RCS: Revision 1997/02/28 16:19:29 ram
+?RCS: patch61: added <unistd.h> and <stdlib.h> to the C program test
+?RCS: Revision 3.0 1993/08/18 12:09:38 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?X: This unit has been somewhat made obsolete with creation of the
+?X: randfunc function (which finds out how to generate random
+?X: numbers between 0 and 1.
+?MAKE:randbits: cat rm Myread cc i_unistd i_stdlib
+?MAKE: -pick add $@ %<
+?S: This variable contains the eventual value of the RANDBITS symbol,
+?S: which indicates to the C program how many bits of random number
+?S: the rand() function produces.
+?C: This symbol contains the number of bits of random number the rand()
+?C: function produces. Usual values are 15, 16, and 31.
+?H:#define RANDBITS $randbits /**/
+: check for size of random number generator
+echo " "
+case "$randbits" in
+ echo "Checking to see how many bits your rand function produces..." >&4
+ $cat >try.c <<EOCP
+#$i_unistd I_UNISTD
+#$i_stdlib I_STDLIB
+#include <stdio.h>
+#ifdef I_UNISTD
+# include <unistd.h>
+#ifdef I_STDLIB
+# include <stdlib.h>
+ $cat >>try.c <<'EOCP'
+ register int i;
+ register unsigned long tmp;
+ register unsigned long max = 0L;
+ for (i = 1000; i; i--) {
+ tmp = (unsigned long)rand();
+ if (tmp > max) max = tmp;
+ }
+ for (i = 0; max; i++)
+ max /= 2;
+ printf("%d\n",i);
+ if $cc try.c -o try >/dev/null 2>&1 ; then
+ dflt=`try`
+ else
+ dflt='?'
+ echo "(I can't seem to compile the test program...)"
+ fi
+ ;;
+ dflt="$randbits"
+ ;;
+rp='How many bits does your rand() function produce?'
+. ./myread
+$rm -f try.c try