ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 77f347d was
0438091,
checked in by Peter A. Buhr <pabuhr@…>, 9 years ago
|
modify stdlib random to not use C library routine
|
-
Property mode set to
100644
|
File size:
843 bytes
|
Line | |
---|
1 | extern "C" { |
---|
2 | #include <unistd.h> // getpid |
---|
3 | } // extern "C" |
---|
4 | |
---|
5 | #include <fstream> |
---|
6 | #include <stdlib> // random |
---|
7 | |
---|
8 | int main() { |
---|
9 | rand48seed( getpid() ); // set random seed |
---|
10 | |
---|
11 | // test polymorphic calls to random and stream |
---|
12 | char c = rand48(); |
---|
13 | sout | c | endl; |
---|
14 | int i = rand48(); |
---|
15 | sout | i | endl; |
---|
16 | unsigned int ui = rand48(); |
---|
17 | sout | ui | endl; |
---|
18 | long int li = rand48(); |
---|
19 | sout | li | endl; |
---|
20 | unsigned long int uli = rand48(); |
---|
21 | sout | uli | endl; |
---|
22 | float f = rand48(); |
---|
23 | sout | f | endl; |
---|
24 | double d = rand48(); |
---|
25 | sout | d | endl; |
---|
26 | float _Complex fc = rand48(); |
---|
27 | sout | fc | endl; |
---|
28 | double _Complex dc = rand48(); |
---|
29 | sout | dc | endl; |
---|
30 | long double _Complex ldc = rand48(); |
---|
31 | sout | ldc | endl; |
---|
32 | } // main |
---|
33 | |
---|
34 | // Local Variables: // |
---|
35 | // tab-width: 4 // |
---|
36 | // compile-command: "cfa random.c" // |
---|
37 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.