1 /***********************************************************************************
2   random_number.cpp
3 
4  * Copyright (c) 1997
5  * Mark of the Unicorn, Inc.
6  *
7  * Permission to use, copy, modify, distribute and sell this software
8  * and its documentation for any purpose is hereby granted without fee,
9  * provided that the above copyright notice appear in all copies and
10  * that both that copyright notice and this permission notice appear
11  * in supporting documentation.  Mark of the Unicorn makes no
12  * representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied warranty.
14 
15 ***********************************************************************************/
16 #include "random_number.h"
17 #include "Prefix.h"
18 #if defined (EH_NEW_HEADERS)
19 # include <functional>
20 # include <cstdlib>
21 #else
22 # include <function.h>
23 # include <stdlib.h>
24 #endif
25 
random_number(size_t range)26 unsigned random_number( size_t range )
27 {
28 #if !defined( __SGI_STL )
29   if (range == 0) return 0;
30   return (unsigned)(EH_STD::rand() + EH_STD::rand()) % range;
31 #else
32   static EH_STD::subtractive_rng rnd;
33         if (range==0) return 0;
34         return rnd(range);
35 #endif
36 }
37 
38 // default base for random container sizes
39 unsigned random_base = 1000;
40