Hello,
I've been working on this random number generator code and got it to work using integer outputs, however I need scientific notation. I read on a site that I can use %E for scientific notation, however I get wierd results that aren't really random, and results that are extremely small like 4.880590E-313 (This is the form I need) when I use it. In addition to this, the output numbers that are on the same line don't seem to change value as they did when they were integers. Can someone please help me, I'm really stuck, I have included my working code that displays integers below. Thanks,
-Al
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
int main ()
{
srand ( time(NULL) );
printf (")O+_06 Big-body initial data (WARNING: Do not delete this line!!\n)");
printf (") Lines beginning with `)' are ignored.\n");
printf (")---------------------------------------------------------------------\n");
printf (" style (Cartesian, Asteroidal, Cometary) = Cartesian\n");
printf (" epoch (in days) = 2451000.5\n");
printf (")---------------------------------------------------------------------\n");
printf ("JUPITER m=%d r=20.d0 d=%d\n", rand()%20, rand()%10);
printf ("%d %d %d \n", rand()%10, rand()%10, rand()%10);
printf ("%d %d %d \n", rand()%10, rand()%10, rand()%10);
// printf ("SATURN m=%E r=20.d0 d=%d \n", rand()%100, rand()%5);
// printf ("%E %E %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
// printf ("%E %E %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
// printf ("URANUS m=%E r=20.d0 d=%d \n", rand()%100, rand()%5);
// printf ("%E %d %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
// printf ("%E %E %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
// printf ("NEPTUNE m=%E r=20.d0 d=%d \n", rand()%100, rand()%5);
// printf ("%E %E %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
// printf ("%E %E %E \n", rand()%10+20, rand()%10+20, rand()%10+20);
return 0;
}
<< moderator edit: added [code][/code] tags >>