Math Functions
All trigonometric functions use radians.
ABS
ABS(Value)
Returns the absolute value of Value.
Returns: Double
Examples:
ABS(-5) ' 5
ABS(-3.14) ' 3.14
ACos
ACos(Value)
Returns the arc cosine of Value in radians. Value must be in the range [-1, 1].
Returns: Double (radians)
Examples:
ACos(1) ' 0.0
ACos(0) ' 1.5708 (π/2)
ACos(-1) ' 3.1416 (π)
ASin
ASin(Value)
Returns the arc sine of Value in radians. Value must be in the range [-1, 1].
Returns: Double (radians)
Examples:
ASin(0) ' 0.0
ASin(1) ' 1.5708 (π/2)
ATan
ATan(Value)
Returns the arc tangent of Value in radians.
Returns: Double (radians)
Examples:
ATan(1) ' 0.7854 (π/4)
ATan(0) ' 0.0
Ceiling
Ceiling(Value)
Rounds Value up to the nearest integer (toward positive infinity).
Returns: Double
Examples:
Ceiling(4.1) ' 5
Ceiling(4.9) ' 5
Ceiling(-4.1) ' -4
Clamp
Clamp(Value, MinValue, MaxValue)
Constrains Value to the range [MinValue, MaxValue]. If Value is below MinValue, returns MinValue. If above MaxValue, returns MaxValue.
| Parameter | Description |
|---|---|
Value |
The value to clamp |
MinValue |
The minimum allowed value |
MaxValue |
The maximum allowed value |
Returns: Double
Examples:
Clamp(150, 0, 100) ' 100
Clamp(-5, 0, 100) ' 0
Clamp(50, 0, 100) ' 50
Cos
Cos(Value)
Returns the cosine of Value (in radians).
Returns: Double
Examples:
Cos(0) ' 1.0
Cos(PI) ' -1.0
Fix
Fix(Value)
Returns the integer portion of Value by truncating toward zero (no rounding).
Returns: Integer
Examples:
Fix(4.9) ' 4
Fix(-4.9) ' -4
Note: Unlike
Floor,Fixtruncates toward zero, soFix(-4.9)=-4not-5.
Floor
Floor(Value)
Rounds Value down to the nearest integer (toward negative infinity).
Returns: Double
Examples:
Floor(4.9) ' 4
Floor(-4.1) ' -5
Int
Int(Value)
Converts Value to an integer. Equivalent to Floor for positive numbers; rounds down toward negative infinity.
Returns: Integer
Examples:
Int(4.9) ' 4
Int(-4.1) ' -5
Pow
Pow(Value, Exponent)
Raises Value to the power of Exponent.
| Parameter | Description |
|---|---|
Value |
The base |
Exponent |
The exponent |
Returns: Double
Examples:
Pow(2, 10) ' 1024
Pow(9, 0.5) ' 3.0 (square root)
Tip: The
^operator also computes exponentiation:2 ^ 10=1024.
Round
Round(Value, [Precision])
Rounds Value to the nearest value. If Precision (number of decimal places) is provided, rounds to that many decimal places. If omitted, rounds to the nearest integer.
| Parameter | Description |
|---|---|
Value |
The value to round |
Precision |
(optional) Number of decimal places (default 0) |
Returns: Double
Examples:
Round(3.567) ' 4
Round(3.567, 2) ' 3.57
Round(3.545, 2) ' 3.54 (banker's rounding)
Note: Uses .NET
Math.Roundwhich applies banker's rounding (midpoint rounds to even).
Sin
Sin(Value)
Returns the sine of Value (in radians).
Returns: Double
Examples:
Sin(0) ' 0.0
Sin(PI / 2) ' 1.0
Sqr
Sqr(Value)
Returns the square root of Value. Alias for Sqrt.
Returns: Double
Examples:
Sqr(9) ' 3.0
Sqr(2) ' 1.4142...
Sqrt
Sqrt(Value)
Returns the square root of Value. Equivalent to Sqr.
Returns: Double
Examples:
Sqrt(25) ' 5.0
Sqrt(2) ' 1.4142...
Tan
Tan(Value)
Returns the tangent of Value (in radians).
Returns: Double
Examples:
Tan(0) ' 0.0
Tan(PI / 4) ' 1.0