Aurora has a large number of mathematics functions included as standard compiler and library functions. These functions can be grouped as follows:
Aurora has the following algebraic functions:
Returns the absolute value of a number.
doublenum - double precision variable or number to take the absolute value of.
otherdoublenum - the absolute value is returned as a double precision number (double).
absolutevalue = abs( -1.5 );
In the example above, abs(-1.5) = 1.5
Ceil returns the smallest whole number (integer as a double precision) that is greater than or equal to the input parameter.
Floor returns the largest whole number (integer as a double precision) that is less than or equal to the input parameter.
doublenum - double precision variable or number to take the absolute value of.
otherdouble - the return value for both ceil and floor is a double precision whole number (double).
writeln("-2.5 is between "+ str$( ceil( -2.8 ) )+", "+str$(floor ( -2.8 ) )+"\n"); writeln(" 2.5 is between "+ str$( ceil( 2.8 ) )+", "+str$(floor ( 2.8 ) )+"\n");
In the examples above, ceil(-2.8) = -2.0 , floor(-2.8) = -3.0 , ceil(2.8) = 3.0, and floor(2.8) = 2.0
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().
AnUnSignedInteger - the pseudo random number returned for RAND() is an integer.
someRandomNum - a pseudo random number returned for RND() 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.
Returns the sign a number.
doublenum - double precision variable or number to test.
SGN returns an integer -1 if the number is less than zero, 1 if the number is greater than zero, or 0 if the number equals zero.
// sign.src global sub main() { select sgn(-1.5) { case -1 : writeln ( " -1.5 is a negative number\n" ); case 0 : writeln ( " -1.5 is a zero\n" ); case 1 : writeln ( " -1.5 is a positive number\n" ); } while (GetKey() = ""); return; }
In the example above, sgn(-1.5) = -1
Returns the square root of a number.
doublenum - double precision variable or number that the square root is taken of.
SQRT returns a double precision number (double).
writeln ( "the square root of 25 is " + str$( sqrt( 25.0 ) ) );
In the examples above, sqrt(25.0) = 5.0. Please note that taking the square root of a negative number results in an error and may cause unpredictable results.
Aurora has the following trigonometric functions:
These functions all return the sine of an angle.
SIN returns a double precision sine value of an angle in radians (double).
SIND returns a double precision sine value of an angle in degrees (double).
FSIN returns a single precision (float) sine value of an angle in radians (float).
FSIND returns a single precision (float) sine value of an angle in degrees (float).
doubleradian - double precision variable (double) or number in radians.
doubledegree - double precision variable (double) or number in degrees.
singleradian - single precision variable (float) or number in radians.
singledegree - single precision variable (float) or number in degrees.
doublenum is a double precision number (double), floatnum is a single precision number (float).
// sine.src global sub main() { writeln("Sine of PI/2 radians = " + str$( sin( 3.1416/2 ), 2)+"\n"); writeln("Sine of 90.0 degrees = " + str$( sind( 90.0000 ), 2)+"\n"); while (GetKey() = ""); return; }
In the examples above, sin(3.1416/2) = 1.00 and sind(90.0) = 1.00
pi = 3.14159265358979323846264338327950288419716939937511
These functions all return the cosine of an angle.
COS returns a double precision cosine value of an angle in radians (double).
COSD returns a double precision cosine value of an angle in degrees (double).
FCOS returns a single precision (float) cosine value of an angle in radians (float).
FCOSD returns a single precision (float) cosine value of an angle in degrees (float).
doubleradian - double precision variable (double) or number in radians.
doubledegree - double precision variable (double) or number in degrees.
singleradian - single precision variable (float) or number in radians.
singledegree - single precision variable (float) or number in degrees.
doublenum is a double precision number (double), floatnum is a single precision number (float).
// cosine.src global sub main() { writeln("Cosine of PI/2 radians = " + str$( cos( 3.1416/2 ), 2)+"\n"); writeln("Cosine of 90.0 degrees = " + str$( cosd( 90.0000 ), 2)+"\n"); while (GetKey() = ""); return; }
In the examples above, cos(3.1416/2) = 0.00 and cosd(90.0) = 0.00
pi = 3.14159265358979323846264338327950288419716939937511
These functions all return the tangent of an angle.
TAN returns a double precision tangent value of an angle in radians (double).
TAND returns a double precision tangent value of an angle in degrees (double).
FTAN returns a single precision (float) tangent value of an angle in radians (float).
FTAND returns a single precision (float) tangent value of an angle in degrees (float).
doubleradian - double precision variable (double) or number in radians.
doubledegree - double precision variable (double) or number in degrees.
singleradian - single precision variable (float) or number in radians.
singledegree - single precision variable (float) or number in degrees.
doublenum is a double precision number (double), floatnum is a single precision number (float).
// tangent.src global sub main() { writeln("Tangent of PI/4 radians = " + str$( tan( 3.1416/4 ), 2)+"\n"); writeln("Tangent of 45.0 degrees = " + str$( tand( 45.0000 ), 2)+"\n"); while (GetKey() = ""); return; }
In the examples above, tan(3.1416/4) = 1.00 and tand(45.0) = 1.00
pi = 3.14159265358979323846264338327950288419716939937511
These functions all return the Arcsine of an angle.
ASIN returns a double precision Arcsine value of an angle in radians (double).
ASIND returns a double precision Arcsine value of an angle in degrees (double).
FASIN returns a single precision (float) Arcsine value of an angle in radians (float).
FASIND returns a single precision (float) Arcsine value of an angle in degrees (float).
doublenum is a double precision number (double)
floatnum is a single precision number (float).
doubleradian - double precision variable or number in radians.
doubledegree - double precision variable or number in degrees.
singleradian - single precision variable or number in radians.
singledegree - single precision variable or number in degrees.
// arcsine.src global sub main() { writeln("Arcsine of 1.0 = " + str$( ASIN( 1.0 ), 3)+" radians\n"); writeln("Arcsine of 1.0 = " + str$( ASIND( 1.0 ), 2)+" degrees\n"); while (GetKey() = ""); return; }
In the examples above, ASIN(1.0) = 1.571 radians and ASIND(1.0) = 90.00 degrees
pi = 3.14159265358979323846264338327950288419716939937511
These functions all return the Arccosine of an angle.
ASIN returns a double precision Arccosine value of an angle in radians (double).
ASIND returns a double precision Arccosine value of an angle in degrees (double).
FASIN returns a single precision (float) Arccosine value of an angle in radians (float).
FASIND returns a single precision (float) Arccosine value of an angle in degrees (float).
doublenum is a double precision number (double)
floatnum is a single precision number (float).
doubleradian - double precision variable or number in radians.
doubledegree - double precision variable or number in degrees.
singleradian - single precision variable or number in radians.
singledegree - single precision variable or number in degrees.
// arccosine.src global sub main() { writeln("Arccosine of 0.0 = " + str$( ACOS( 0.0 ), 3)+" radians\n"); writeln("Arccosine of 0.0 = " + str$( ACOSD( 0.0 ), 2)+" degrees\n"); while (GetKey() = ""); return; }
In the examples above, ACOS(1.0) = 1.571 radians and ACOSD(1.0) = 90.00 degrees
pi = 3.14159265358979323846264338327950288419716939937511
These functions all return the Arctangent of an angle.
ASIN returns a double precision Arctangent value of an angle in radians (double).
ASIND returns a double precision Arctangent value of an angle in degrees (double).
FASIN returns a single precision (float) Arctangent value of an angle in radians (float).
FASIND returns a single precision (float) Arctangent value of an angle in degrees (float).
doublenum is a double precision number (double)
floatnum is a single precision number (float).
doubleradian - double precision variable or number in radians.
doubledegree - double precision variable or number in degrees.
singleradian - single precision variable or number in radians.
singledegree - single precision variable or number in degrees.
// arctangent.src global sub main() { writeln("Arctangent of 1.0 = " + str$( ATAN( 1.0 ), 3)+" radians\n"); writeln("Arctangent of 1.0 = " + str$( ATAND( 1.0 ), 2)+" degrees\n"); while (GetKey() = ""); return; }
In the examples above, ATAN(1.0) = 0.785 radians and ATAND(1.0) = 45.00 degrees
pi = 3.14159265358979323846264338327950288419716939937511
Aurora has the following logarithmic and Exponential functions:
Calculates the Natural Logarithm ( ln = Log Base e ) of a number.
Note: e = 2.71828182845904523536028747135266249775724709369996...
doublenum is a double precision number (double) must be greater than zero.
otherdoublenum - double precision variable or number.
// log.src global sub main() { writeln("Natural Log (ln) of 10.0 = " + str$( LOG( 10.0 ), 4) + "\n"); while (GetKey() = ""); return; }
In the examples above, LOG(10.0) = 2.3026
The logarithm of a number unless the number is less than or equal to zero. If the input is less than zero then the result is indefinite (undefined). If the input is equal to zero then the result is infinite (undefined) and cannot be represented.
Calculates the Base 10 Logarithm of a number.
doublenum is a double precision number (double) must be greater than zero.
otherdoublenum - double precision variable or number.
// log10.src global sub main() { writeln("Natural Log Base 10 of 10.0 = " + str$( LOG10( 10.0 ), 4) + "\n"); while (GetKey() = ""); return; }
In the examples above, LOG(10.0) = 1.0000
The logarithm of a number unless the number is less than or equal to zero. If the input is less than zero then the result is indefinite (undefined). If the input is equal to zero then the result is infinite (undefined) and cannot be represented.
Calculates a positive double precision number (double) equal to e raised to the doublenum power (e^doublenum).
Note: e = 2.71828182845904523536028747135266249775724709369996...
doublenum is a double precision number (double) must be greater than zero.
otherdoublenum - double precision variable or number (double).
// exp.src global sub main() { writeln("e^2 = " + str$( EXP( 2.0 ), 4) + "\n"); while (GetKey() = ""); return; }
In the examples above, EXP(2.0) = 7.3891
Hyperbolic functions are functions which involve exponents of e (e^x) such as:
SINH(x) = FSINH(x) = (e^(x) - e^(-x)) / 2 and COSH(x) = FCOSH(x) = (e^(x) + e^(-x)) / 2
Aurora has the following Hyperbolic functions:
SINH calculates a double precision number (double) equal to the Hyperbolic Sine of a double number (double)
FSINH calculates a single precision number (float) equal to the Hyperbolic Sine of a single number (float)
SINH(x) = FSINH(x) = (e^(x) - e^(-x)) / 2
Note: e = 2.71828182845904523536028747135266249775724709369996...
doublenum is a double precision variable or number (double).
singlenum is a single precision variable or number (float).
otherdoublenum - double precision variable or number (double).
othersinglenum - single precision variable or number (float).
// sinh.src global sub main() { double x; for ( x = -10; x <= 10; x++ ) // For Loop, x= -10 to 10, increment (step) x by 1 { writeln("x = " + str$( x ) + " , "); writeln("SINH(x) = " + str$( sinh( x ), 2 ) + "\n"); } while (GetKey() = ""); return; }
In the example above, sinh(-10.0) = -11013.23, sinh(0.0) = 0.0, sinh(10.0) = 11013.23
COSH calculates a double precision number (double) equal to the Hyperbolic Cosine of a double number (double)
FCOSH calculates a single precision number (float) equal to the Hyperbolic Cosine of a single number (float)
COSH(x) = FCOSH(x) = (e^(x) + e^(-x)) / 2
Note: e = 2.71828182845904523536028747135266249775724709369996...
doublenum is a double precision variable or number (double).
singlenum is a single precision variable or number (float).
otherdoublenum - double precision variable or number (double).
othersinglenum - single precision variable or number (float).
// cosh.src global sub main() { double x; for ( x = -10; x <= 10; x++ ) // For Loop, x= -10 to 10, increment (step) x by 1 { writeln("x = " + str$( x ) + " , "); writeln("COSH(x) = " + str$( cosh( x ), 2 ) + "\n"); } while (GetKey() = ""); return; }
In the example above, cosh(-10.0) = 11013.23, cosh(0.0) = 1.0, cosh(10.0) = 11013.23
TANH calculates a double precision number (double) equal to the Hyperbolic Tangent of a double number (double)
FTANH calculates a single precision number (float) equal to the Hyperbolic Tangent of a single number (float)
Note: TANH(x) = SINH(x) / COSH(x) , FTANH(x) = FSINH(x) / FCOSH(x)
doublenum is a double precision variable or number (double).
singlenum is a single precision variable or number (float).
otherdoublenum - double precision variable or number (double).
othersinglenum - single precision variable or number (float).
// tanh.src global sub main() { double x; for ( x = -10; x <= 10; x++ ) // For Loop, x= -10 to 10, increment (step) x by 1 { writeln("x = " + str$( x ) + " , "); writeln("TANH(x) = " + str$( tanh( x ), 2 ) + "\n"); } while (GetKey() = ""); return; }
In the example above, tanh(-10.0) = -1.00, tanh(0.0) = 0.0, tanh(10.0) = 1.00