9.5 Math object
Description
You can apply many mathematical operations (trigonometry, logarithmize, square root, rounding, ...) with the Math object.
List of methods/properties
Name | Type | Short description |
Pi | Property | Returns Ludolph's number (π = 3,141592653589...) |
E | Property | Returns Euler's number (e = 2,718281828...) |
Abs | Method | Returns the absolute value of a number |
Sin | Method | Calculates the sine of an angle |
Cos | Method | Calculates the cosine of an angle |
Tan | Method | Calculates the tangent of an angle |
Cot | Method | Calculates the cotangent of an angle |
Sec | Method | Calculates the sekant of an angle |
Csc | Method | Calculates the cosekant of an angle |
ASin | Method | Calculates the angle of a sine |
ACos | Method | Calculates the angle of a cosine |
ATan | Method | Calculates the angle of a tangent |
ACot | Method | Calculates the angle of a cotangent |
ASec | Method | Calculates the angle of a sekant |
ACsc | Method | Calculates the angle of a cosekant |
SinH | Method | Calculates the hyperbolic sine |
CosH | Method | Calculates the hyperbolic cosine |
TanH | Method | Calculates the hyperbolic tangent |
CotH | Method | Calculates the hyperbolic cotangent |
SecH | Method | Calculates the hyperbolic sekant |
CscH | Method | Calculates the hyperbolic cosekant |
ASinH | Method | Calculates the inverted hyperbolic sine |
ACosH | Method | Calculates the inverted hyperbolic cosine |
ATanH | Method | Calculates the inverted hyperbolic tangent |
ACotH | Method | Calculates the inverted hyperbolic cotangent |
ASecH | Method | Calculates the inverted hyperbolic sekant |
ACscH | Method | Calculates the inverted hyperbolic cosekant |
Power | Method | Exponentiates a base with an exponent |
Log | Method | Calculates the logarithm to any base |
Lg | Method | Calculates the decade logarithm (base: 10) |
Ln | Method | Calculates the natural logarithm (base: e = 2,718281828...) |
Lb | Method | Calculates the binary logarithm (base: 2) |
Sqrt | Method | Calculates the square root of a number |
Cmp | Method | Compares two values |
Exp | Method | Exponates the number 10 with an exponent |
Round | Method | Rounds a number halfway away from zero |
RoundUp | Method | Rounds a number in direction to +∞ |
RoundDown | Method | Rounds a number in direction to -∞ |
Int | Method | Cuts the decimal places of a number |
Scale | Method | Cuts the integer places of a number |
Description
This property represents Ludolph's number (π = 3,141592653589...).
Syntax
Data type
Double
Type
Property, read-only
Example
f[1] whould be at end: 3,141592653589...
Description
This property represents Euler's number (e = 2,718281828...).
Syntax
Data type
Double
Type
Property, read-only
Example
f[1] whould be at end: 2,718281828...
Description
Returns the absolute value of a number (this means the leading sign will always be plus).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose absolute value shall be returned.
Data type
Double
Example
f[1] whould be at end: 2
Description
Calculates the sine of an angle (= opposite leg / hypotenuse). You can specify the angle in one of four angle formats: DEG, RAD, GRAD and RPG. These names are specified as constants and can be used directly as parameter. DEG stands for degree and means that a full circle has 360 angle units. RAD stands for radiant and means that the radian measure (a full circle has π angle units) is used. GRAD stands for grad and means that a full circle has 400 angle units. RPG is a RPG-Maker specific format and means that a full circle has 256 angle units.
Syntax
1
Math.Sin(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Sin(90, DEG)
f[1] whould be at end: 1
Description
Calculates the cosine of an angle (= adjacent leg / hypotenuse). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Cos(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Cos(Math.Pi, RAD)
f[1] whould be at end: -1
Description
Calculates the tangent of an angle (= opposite leg / adjacent leg). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Tan(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Tan(50, GRAD)
f[1] whould be at end: 1
Description
Calculates the cotangent of an angle (= adjacent leg / opposite leg). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Cot(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Cot(96, RPG)
f[1] whould be at end: -1
Description
Calculates the sekant of an angle (= hypotenuse / adjacent leg). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Sec(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Sec(45, DEG)
f[1] whould be at end: 1,414213562373...
Description
Calculates the cosekant of an angle (= hypotenuse / opposite leg). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Csc(Angle, Format)
Return value
Double
Type
Method
Parameter: Angle
Description
The angle which shall be calculated.
Data type
Double
Parameter: Format
Description
The current format of the angle.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Csc(30, DEG)
f[1] whould be at end: 2
Description
Calculates the angle from a sine (= arc sine). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Asin(Sine, Format)
Return value
Double
Type
Method
Parameter: Sine
Description
The sine value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Asin(30, DEG)
f[1] whould be at end: 30
Description
Calculates the angle from a cosine (arc cosine). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Acos(Cosine, Format)
Return value
Double
Type
Method
Parameter: Cosine
Description
The cosine value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Acos(1, GRAD)
f[1] whould be at end: 0
Description
Calculates the angle from a tangent (= arc tangent). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Atan(Tangent, Format)
Return value
Double
Type
Method
Parameter: Tangent
Description
The tangent value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Atan(1, DEG)
f[1] whould be at end: 45
Description
Calculates the angle from a cotangent (= arc cotangent). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Acot(Cotangent, Format)
Return value
Double
Type
Method
Parameter: Cotangent
Description
The cotangent value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Acot(-1, DEG)
f[1] whould be at end: 135 (= -45)
Description
Calculates the angle from a sekant (= arc sekant). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Asec(Sekant, Format)
Return value
Double
Type
Method
Parameter: Sekant
Description
The sekant value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Asec(2, DEG)
f[1] whould be at end: 60
Description
Calculates the angle from a cosekant (= arc cosekant). (For a description of the angle formats see
Sin method)
Syntax
1
Math.Acsc(Cosekant, Format)
Return value
Double
Type
Method
Parameter: Cosekant
Description
The cosekant value.
Data type
Double
Parameter: Format
Description
The target angle format.
Data type
Dword
Range
1 to 4 (Constants: DEG, RAD, GRAD and RPG)
Example
1
2
$
f[1] = Math.Acsc(1, RPG)
f[1] whould be at end: 64
Description
Calculates the hyperbolic sine.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Sinh(f[2])
Description
Calculates the hyperbolic cosine.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Cosh(f[2])
Description
Calculates the hyperbolic tangent.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Tanh(f[2])
Description
Calculates the hyperbolic cotangent.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Coth(f[2])
Description
Calculates the hyperbolic sekant.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Sech(f[2])
Description
Calculates the hyperbolic cotangent.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Csch(f[2])
Description
Calculates the inverted hyperbolic sine (area hyperbolic sine).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Asinh(f[2])
Description
Calculates the inverted hyperbolic cosine (area hyperbolic cosine).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Acosh(f[2])
Description
Calculates the inverted hyperbolic tangent (area hyperbolic tangent).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Atanh(f[2])
Description
Calculates the inverted hyperbolic cotangent (area hyperbolic cotangent).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Acoth(f[2])
Description
Calculates the inverted hyperbolic sekant (area hyperbolic sekant).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Asech(f[2])
Description
Calculates the inverted hyperbolic cosekant (area hyperbolic cosekant).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Acsch(f[2])
Description
Exponentiates the base with the exponent.
Syntax
1
Math.Power(Base, Exponent)
Return value
Double
Type
Method
Parameter: Base
Description
The base value.
Data type
Double
Parameter: Exponent
Description
The exponent value.
Data type
Double
Example
1
2
$
f[1] = Math.Power(3, 4)
f[1] whould be at end: 81 (= 3 * 3 * 3 * 3)
Description
Calculates the logarithm of any base.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose logarithm shall be calculated.
Data type
Double
Parameter: Base
Description
The base of the logarithm.
Data type
Double
Example
1
2
$
f[1] = Math.Log(25, 5)
f[1] whould be at end: 2
Description
Calculates the decade logarithm (the base is 10).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose logarithm shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Lg(1000)
f[1] whould be at end: 3
Description
Calculates the natural logarith (the base is Euler's number).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose logarithm shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Ln(1 / Math.E)
f[1] whould be at end: -1
Description
Calculates the binary logarithm (the base is 2).
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose logarithm shall be calculated.
Data type
Double
Example
f[1] whould be at end: 8
Description
Calculates the square root of a number.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose square root shall be calculated.
Data type
Double
Example
1
2
$
f[1] = Math.Sqrt(10000)
f[1] whould be at end: 100
Description
Compares two numbers. If the first number is smaller than the second number then the result will be < 0. If the first number is greater than the second number then the result will be > 0. If both numbers are the same then the result will be = 0.
Syntax
1
Math.Cmp(Number1, Number2)
Return value
Dword
Type
Method
Parameter: Number1
Description
The first number to compare.
Data type
Double
Parameter: Number2
Description
The second number to compare.
Data type
Double
Example
1
2
$
d[1] = Math.Cmp(1, 2)
f[1] whould be at end: -1
Description
Exponentiates the number 10 with the specified number.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The exponent for the number 10.
Data type
Double
Example
f[1] whould be at end: 100000
Description
Rounds a number halfway away from zero (this means 5 to 9 will be rounded up) to the specified place. If you specify 0 as place then the decimal part will be rounded to the integer part. If you specify a positive number as place then you round to that decimal place. If you specify a negative number as place then you round to that integer place.
Syntax
1
Math.Round(Number, Place)
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be rounded.
Data type
Double
Parameter: Place
Description
The place which shall be rounded (measured from the decimal separator).
Data type
Dword
Example
1
2
$
f[1] = Math.Round(3.345, 2)
f[1] whould be at end: 3.35
Description
Rounds a number into the direction of +∞ (this means from 1 to 9 will be rounded up) to the specified place. If you specify 0 as place then the decimal part will be rounded to the integer part. If you specify a positive number as place then you round to that decimal place. If you specify a negative number as place then you round to that integer place.
Syntax
1
Math.RoundUp(Number, Place)
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be rounded.
Data type
Double
Parameter: Place
Description
The place which shall be rounded (measured from the decimal separator).
Data type
Dword
Example
1
2
$
f[1] = Math.RoundUp(-300.7, 0)
f[1] whould be at end: -300 (if you round into the direction of +∞ then the result will always be more positive)
Description
Rounds a number into the direction of -∞ (this means from 1 to 9 will be rounded down) to the specified place. If you specify 0 as place then the decimal part will be rounded to the integer part. If you specify a positive number as place then you round to that decimal place. If you specify a negative number as place then you round to that integer place.
Syntax
1
Math.RoundDown(Number, Place)
Return value
Double
Type
Method
Parameter: Number
Description
The number which shall be rounded.
Data type
Double
Parameter: Place
Description
The place which shall be rounded (measured from the decimal separator).
Data type
Dword
Example
1
2
$
f[1] = Math.RoundDown(592.001, -2)
f[1] whould be at end: 500
Description
Cuts the decimal part of a number.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose decimal part shall be removed.
Data type
Double
Example
1
2
$
f[1] = Math.Int(123.456)
f[1] whould be at end: 123
Description
Cuts the integer part of a number.
Syntax
Return value
Double
Type
Method
Parameter: Number
Description
The number whose integer part shall be removed.
Data type
Double
Example
1
2
$
f[1] = Math.Scale(123.456)
f[1] whould be at end: 0,456