TEIMSI
Developer's platform of programming text codes
Home|Utilities|Forum|Documentation

Table of contents -> Chapter 11 - Functions for Math


The next topic is the description for the use of the following predefined TEIMSI functions:

1)- abs(number)

2)- acos(number)

3)- asin(number)

4)- atan(number)

5)- atanxy(number,number)

6)- cos(number)

7)- exp(number)

8)- facto(number)

9)- floor(number)

10)- ln(number)

11)- max(number,number)

12)- min(number,number)

13)- rnd()

14)- randomize()

15)- randomize_from_key(string)

16)- ron(number)

17)- sgn(number)

18)- sin(number)

19)- sqrt(number)

20)- tan(number)




abs

The "abs" function determines the absolute value of a number (it passes a number to positive if it's negative).


Syntax
abs(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(abs(2.3))	//	Shows "2.3"
	alert(abs(-2.3))	//	Shows "2.3"



See also <<sgn>>


Go to top

acos

The "acos" function calculates the arc cosine of a decimal number between -1 and 1. The resulting value is another number between _PI and 0, the function is the inverse of the "cos" (cosine) function.


Syntax
acos(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(acos(-1))	//	Shows _PI.
	alert(acos(0))	//	Shows _PI/2.
	alert(acos(1))	//	Shows 0.



See also <<cos>>


Go to top

asin

The "asin" function finds the arc sine of a decimal number between -1 and 1. The resulting value is another number between -_PI/2 and _PI/2, the function is the inverse of the "sin" function (sine function).


Syntax
asin(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(asin(-0.9999))	//	Shows ~ -_PI/2.
	alert(asin(0))	//	Shows 0.
	alert(asin(0.9999))	//	Shows ~ _PI/2.


See also <<acos>>, <<atan>>


Go to top

atan

The "atan" function is the arctangent of a decimal number between -infinity and +infinity. The resulting value is another number between -_PI/2 and _PI/2, the function is the inverse of the "tan" function (tangent function).


Syntax
atan(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(atan(1000000))		// 	Shows ~ _PI/2 = 1.57079...


See also <<tan>>


Go to top

atanxy

The "atanxy" function finds the angle (in radians and range of 0 to 2*_PI) in the vertex (0,0) of the triangle (x,y),(0,0),(1,0) within a rectangular and cartesian two-dimensional plane.


Syntax
atanxy(decimal_number1,decimal_number2)
 

Parameters
decimal_number1
TEIMSI variable with data type of floating point number.
 
decimal_number2
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(atanxy(-1,-1))	//	Shows 3.926 ... = (5/8)*2*_PI = 225
	alert(atanxy(1,-1))	//	Shows 5.497 ... = (7/8)*2*_PI = 315
	alert(atanxy(1,1))		//	Shows 0.785 ... = (1/8)*2*_PI = 45
	alert(atanxy(-1,1))	//	Shows 2.356 ... = (3/8)*2*_PI = 135



See also <<atan>>


Go to top

cos

The "cos" function determines the cosine of a number that represents an angle in radians.


Syntax
cos(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(cos(3.14159))		//	Shows Approx. -1.



See also <<sin>>, <<tan>>


Go to top

exp

The "exp" function finds "e" (2.71828182 ...) raised to the number that is passed as a parameter.


Syntax
exp(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(exp(1))		//	Shows e, 2,71828 ...


See also <<ln>>


Go to top

facto

The "facto" function receives a non-negative integer and returns the factorial number. For example facto(4) =4*3*2*1=24, facto(8) =8*7*6*5*4*3*2*1=40320.


Syntax
facto(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(facto(8));



See also <<floor>>


Go to top

floor

The "floor" function returns the integer part of a decimal number.


Syntax
floor(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(floor(5.3))	//	Shows "5"



See also <<ron>>


Go to top

ln

The "ln" function finds the logarithm base to "e" (2.71828 ...) of a positive decimal number. It is the inverse function to the exp function.


Syntax
ln(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	// _E=2.718281828

	alert(ln(_E))	//	Shows approximately 1.



See also <<exp>>


Go to top

max

The "max" function receives two numbers and returns the greatest of them.


Syntax
max(decimal_number1,decimal_number2)
 

Parameters
decimal_number1
TEIMSI variable with data type of floating point number.
 
decimal_number2
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:


	alert(max(32,31.2))	//	Shows 32.



See also <<min>>


Go to top

min

The "min" function receives two numbers and returns the smallest of them.


Syntax
min(decimal_number1,decimal_number2)
 

Parameters
decimal_number1
TEIMSI variable with data type of floating point number.
 
decimal_number2
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(min(32,31.2))	//	Shows 31.2



See also <<max>>


Go to top

rnd

The "rnd" function returns a random decimal number between 0 and 1.


Syntax
rnd()
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(rnd())



See also <<floor>>


Go to top

randomize

The "randomize" function randomly initializes the seed for the "rnd" values generator.


Syntax
randomize()
 

Returned value
Boolean
TEIMSI variable with a "true" boolean.
 

Example:



	alert(rnd())

	randomize()

	alert(rnd())



See also <<randomize_from_key>>


Go to top

randomize_from_key

The "randomize_from_key" function receives a "key" string for the initialization of the random seed for the "rnd" values generator procedure.


Syntax
randomize_from_key(string)
 

Parameters
string
TEIMSI variable with a string data type.
 

Returned value
Boolean
TEIMSI variable with a boolean data type with a value of "true" if no error has occured.
 

Example:



	alert(rnd())

	randomize_from_key("random 1")

	alert(rnd())



See also <<randomize>>


Go to top

ron

The "ron" function rounds a number to the nearest integer.


Syntax
ron(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(ron(1.6))	//	Shows "2".


See also <<floor>>


Go to top

sgn

The "sgn" function returns an integer of three possible: -1, 0, 1. The -1 if you send it a negative number, 0 if zero and 1 if a positive one.


Syntax
sgn(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(sgn(-12))	//	Shows "-1".


See also <<abs>>


Go to top

sin

The "sin" function determines the sine of a number that represents an angle in radians.


Syntax
sin(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(sin(3.14159))		//	Shows 0.



See also <<cos>>, <<tan>>


Go to top

sqrt

The "sqrt" function finds the square root of a nonnegative number.


Syntax
sqrt(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	alert(sqrt(9))	//	Shows "3".


See also <<exp>>


Go to top

tan

The "tan" function determines the tangent of a number that represents an angle in radians.


Syntax
tan(decimal_number)
 

Parameters
decimal_number
TEIMSI variable with data type of floating point number.
 

Returned value
decimal_number
TEIMSI variable with data type of floating point number.
 

Example:



	// _PI=3.141592654....

	alert(tan(_PI/4))		//	Shows 1.



See also <<sin>>, <<cos>>


Go to top