mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-04 17:58:22 +00:00
a7a1c7e971
This directory needs to be reorganized and some of the tests need changes to make them executable. Also comments would help... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2865 91177308-0d34-0410-b5e6-96231b3b80d8
30 lines
569 B
C
30 lines
569 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define A 16807.0
|
|
#define M 2147483647.0
|
|
|
|
/*
|
|
* This function calls floor() which does not have a prototype.
|
|
* Test that the argument to floor is passed correctly.
|
|
*/
|
|
double
|
|
my_rand(double seed)
|
|
{
|
|
double t = A*seed + 1;
|
|
double floor();
|
|
|
|
seed = t - (M * floor(t / M)); /* t%M if t > M; t otherwise */
|
|
return seed;
|
|
|
|
} /* end of random */
|
|
|
|
|
|
int
|
|
main(int argc, char** argv)
|
|
{
|
|
double seed = 123 * ((argc > 1)? atof(argv[1]) : 3.1415926);
|
|
printf("my_rand(%lf) = %lf\n", seed, my_rand(seed));
|
|
return 0;
|
|
}
|