9.5 Math object

Description

You can apply many mathematical operations (trigonometry, logarithmize, square root, rounding, ...) with the Math object.

List of methods/properties

NameTypeShort description
PiPropertyReturns Ludolph's number (π = 3,141592653589...)
EPropertyReturns Euler's number (e = 2,718281828...)
AbsMethodReturns the absolute value of a number
SinMethodCalculates the sine of an angle
CosMethodCalculates the cosine of an angle
TanMethodCalculates the tangent of an angle
CotMethodCalculates the cotangent of an angle
SecMethodCalculates the sekant of an angle
CscMethodCalculates the cosekant of an angle
ASinMethodCalculates the angle of a sine
ACosMethodCalculates the angle of a cosine
ATanMethodCalculates the angle of a tangent
ACotMethodCalculates the angle of a cotangent
ASecMethodCalculates the angle of a sekant
ACscMethodCalculates the angle of a cosekant
SinHMethodCalculates the hyperbolic sine
CosHMethodCalculates the hyperbolic cosine
TanHMethodCalculates the hyperbolic tangent
CotHMethodCalculates the hyperbolic cotangent
SecHMethodCalculates the hyperbolic sekant
CscHMethodCalculates the hyperbolic cosekant
ASinHMethodCalculates the inverted hyperbolic sine
ACosHMethodCalculates the inverted hyperbolic cosine
ATanHMethodCalculates the inverted hyperbolic tangent
ACotHMethodCalculates the inverted hyperbolic cotangent
ASecHMethodCalculates the inverted hyperbolic sekant
ACscHMethodCalculates the inverted hyperbolic cosekant
PowerMethodExponentiates a base with an exponent
LogMethodCalculates the logarithm to any base
LgMethodCalculates the decade logarithm (base: 10)
LnMethodCalculates the natural logarithm (base: e = 2,718281828...)
LbMethodCalculates the binary logarithm (base: 2)
SqrtMethodCalculates the square root of a number
CmpMethodCompares two values
ExpMethodExponates the number 10 with an exponent
RoundMethodRounds a number halfway away from zero
RoundUpMethodRounds a number in direction to +∞
RoundDownMethodRounds a number in direction to -∞
IntMethodCuts the decimal places of a number
ScaleMethodCuts the integer places of a number

Pi

Description

This property represents Ludolph's number (π = 3,141592653589...).

Syntax

1
Math.Pi

Data type

Double

Type

Property, read-only

Example

1
2
$
f[1] = Math.Pi
f[1] whould be at end: 3,141592653589...

E

Description

This property represents Euler's number (e = 2,718281828...).

Syntax

1
Math.E

Data type

Double

Type

Property, read-only

Example

1
2
$
f[1] = Math.E
f[1] whould be at end: 2,718281828...

Abs

Description

Returns the absolute value of a number (this means the leading sign will always be plus).

Syntax

1
Math.Abs(Number)

Return value

Double

Type

Method

Parameter: Number

Description

The number whose absolute value shall be returned.

Data type

Double

Example

1
2
$
f[1] = Math.Abs(-2)
f[1] whould be at end: 2

Sin

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

Cos

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

Tan

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

Cot

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

Sec

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...

Csc

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

ASin

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

ACos

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

ATan

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

ACot

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)

ASec

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

ACsc

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

SinH

Description

Calculates the hyperbolic sine.

Syntax

1
Math.Sinh(Number)

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])

CosH

Description

Calculates the hyperbolic cosine.

Syntax

1
Math.Cosh(Number)

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])

TanH

Description

Calculates the hyperbolic tangent.

Syntax

1
Math.Tanh(Number)

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])

CotH

Description

Calculates the hyperbolic cotangent.

Syntax

1
Math.Coth(Number)

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])

SecH

Description

Calculates the hyperbolic sekant.

Syntax

1
Math.Sech(Number)

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])

CscH

Description

Calculates the hyperbolic cotangent.

Syntax

1
Math.Csch(Number)

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])

ASinH

Description

Calculates the inverted hyperbolic sine (area hyperbolic sine).

Syntax

1
Math.Asinh(Number)

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])

ACosH

Description

Calculates the inverted hyperbolic cosine (area hyperbolic cosine).

Syntax

1
Math.Acosh(Number)

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])

ATanH

Description

Calculates the inverted hyperbolic tangent (area hyperbolic tangent).

Syntax

1
Math.Atanh(Number)

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])

ACotH

Description

Calculates the inverted hyperbolic cotangent (area hyperbolic cotangent).

Syntax

1
Math.Acoth(Number)

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])

ASecH

Description

Calculates the inverted hyperbolic sekant (area hyperbolic sekant).

Syntax

1
Math.Asech(Number)

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])

ACscH

Description

Calculates the inverted hyperbolic cosekant (area hyperbolic cosekant).

Syntax

1
Math.Acsch(Number)

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])

Power

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)

Log

Description

Calculates the logarithm of any base.

Syntax

1
Math.Log(Number, Base)

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

Lg

Description

Calculates the decade logarithm (the base is 10).

Syntax

1
Math.Lg(Number)

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

Ln

Description

Calculates the natural logarith (the base is Euler's number).

Syntax

1
Math.Ln(Number)

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

Lb

Description

Calculates the binary logarithm (the base is 2).

Syntax

1
Math.Lb(Number)

Return value

Double

Type

Method

Parameter: Number

Description

The number whose logarithm shall be calculated.

Data type

Double

Example

1
2
$
f[1] = Math.Lb(256)
f[1] whould be at end: 8

Sqrt

Description

Calculates the square root of a number.

Syntax

1
Math.Sqrt(Number)

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

Cmp

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

Exp

Description

Exponentiates the number 10 with the specified number.

Syntax

1
Math.Exp(Number)

Return value

Double

Type

Method

Parameter: Number

Description

The exponent for the number 10.

Data type

Double

Example

1
2
$
f[1] = Math.Exp(5)
f[1] whould be at end: 100000

Round

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

RoundUp

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)

RoundDown

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

Int

Description

Cuts the decimal part of a number.

Syntax

1
Math.Int(Number)

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

Scale

Description

Cuts the integer part of a number.

Syntax

1
Math.Scale(Number)

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