Math+Functions

=Math Functions= toc

Run BASIC provides several mathematical functions which are described below. See the code following the descriptions for examples.

Abs
ABS(x) //- Absolute value of x//

Absolute value is the value of a number without regard to its sign.

Min
MIN(x, y) //- The lesser of x or y//

Max
MAX(x, y) //- The larger of x or y//

Int
INT(x) //- Integer part of x//

Rnd
RND(n) //- Return a pseudorandom value between 0 and 1//

Log
LOG(x) //- Natural logarithm of x//

This is the inverse function of **Exp**

The natural logarithm is the logarithm to the base e, where e is an irrational constant approximately equal to 2.718281828459. In simple terms, the natural logarithm of a number x is the power to which e would have to be raised to equal x

Exp
EXP(x) //- Return e^x. e=2.7182818//

This is the inverse function of **Log**

Sqr
SQR(x) //- Square root of x//

Code
code format="vbnet" print "absolute value of 15 is ";abs(15) print "absolute value of -15 is ";abs(-15) print "integer portion of 3.14159 is ";int(3.14159) print "max of 13 and 259 is ";max(13,259) print "min of 13 and 259 is ";min(13,259) print "random number between 0 and 1 is ";rnd(0) print "square root of 64 is ";sqr(64) num = log(17) print "natural log of 17 is ";num 'exp and log are inverse functions 'so this prints "17" print "exp of ";num;" is ";exp(num) code

Output: code absolute value of 15 is 15 absolute value of -15 is 15 integer portion of 3.14159 is 3 max of 13 and 259 is 259 min of 13 and 259 is 13 random number between 0 and 1 is 0.240657 square root of 64 is 8 natural log of 17 is 2.83321 exp of 2.83321 is 17 code