Aurora has a large number of mathematics functions included as standard compiler and library functions. These functions can be grouped as follows:
Returns the absolute value of a number.
doublenum - double precision variable or number to take the absolute value of.
The absolute value is returned as a double precision number (double).
absolutevalue = abs( -1.5 );
In the example above, abs(-1.5) = 1.5
The SEEDRND function works with the RAND and RND functions. The SEEDRND function seeds the random number generator with a specific value.
The RAND function creates a pseudo random number {Maximum random range is 0 <= number <= 65535}.
The RND function creates a pseudo random number {Maximum random range is -32765.0 <= number <= 32766.0}.
for SEEDRND intnum shall be an integer value (int)
for RAND usint is the beginning or ending number for the range, and shall be an unsigned integer value (unsigned int),
for RAND optmaxi is an optional interger value, that if given, the random number will be between num and optmaxi. Otherwise random number will be between 0 and num.
for RND num shall be a floating point number value (float),
for RND optmaxf is an optional floating point value, that if given, the random number will be between num and optmaxf. Otherwise random number will be between 0 and num.
There is no value returned for SEEDRND().
The pseudo random number returned for RAND() is an integer.
The pseudo random number returned for RAND() is a single precision number (float).
// random.src
global sub main()
{
seedrnd ( 10021959 );
writeln ( str$( rand ( 100, 25 ) ) + "\n" );
writeln ( str$( rnd ( 15.5, 5.0 ) ) + "\n" );
while (GetKey() = "");
return;
}
On program execution the random number generator seed is set to the current Windows tick count guaranteeing that a repeating random sequence is unlikely to occur. If you use the same seed (by using the SEEDRND function) every time then the random sequence will be identical on successive runs.