Hi
Which function can I use to make random numbers in double.
Normally the rand(), randomize and random is randomizing numbers in int.
How can I get ex. 10 double numbers...
Tx for help
Gugge
Hi
Which function can I use to make random numbers in double.
Normally the rand(), randomize and random is randomizing numbers in int.
How can I get ex. 10 double numbers...
Tx for help
Gugge
!G!
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition
-PreludeCode:double drand ( double low, double high ) { return ( (double)rand() * ( high - low ) ) / (double)RAND_MAX + low; }
My best code is written with the delete key.
Prelude,
Is RAND_MAX valid for all platforms? The reason I'm asking is that I can't seem to use it on my HP-UNIX account at school. I am I doing something wrong. I can use INT_MAX, LONG_MAX, etc.
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition
>Is RAND_MAX valid for all platforms?
RAND_MAX is a macro defined in stdlib.h, it is a standard feature according to ISO C89 and C99. If you aren't including stdlib.h then the compiler probably won't let you use RAND_MAX, but it should also complain about rand() being undefined as well.
-Prelude
My best code is written with the delete key.
I am definatley including stdlib.h, and rand() has no flags or warnings. I have to use this macro in my makefile though:
CFLAGS = -Ae +DAportable
Maybe this is part of it. I know the system is pretty old. Any ideas?
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition
It may be pre-ANSI and not have it, check the documentation to see if there is an alternative. I'm also not familiar with the -Ae flag, what does it do exactly?
-Prelude
My best code is written with the delete key.
I'm clueless as to what the -Ae flag does. I'm guessing it is a command for the linker to use some environment variable to locate some important shared libraries. I will have to ask around.
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition