/* * Copyright 2012 Pedro Giffuni * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include int main(int argc, char **argv) { int initialX, initialY, initialZ; double aleatory; long i = 0; long run = 1000; if (argc > 1) run = atol(argv[1]); srand((unsigned) time(NULL)); /* Seeding is done by Calc, it is only here for testing */ initialX = (rand() % 30000) + 1; initialY = (rand() % 30000) + 1; initialZ = (rand() % 30000) + 1; for (i = 0; i < run; i++) { initialX = (171 * initialX) % 30269; initialY = (172 * initialY) % 30307; initialZ = (170 * initialZ) % 30323; aleatory = ( (double) initialX / 30269.0 + (double) initialY / 30307.0 + (double) initialZ / 30323.0 ) ; printf(" %22.20f IX1 =%6d, IX2 =%6d, IX3 =%6d\n", aleatory - (int) aleatory, initialX, initialY, initialZ) ; } } /* main */