Runtime::Math
- Last UpdatedSep 17, 2025
- 3 minute read
The Runtime::Math class provides common methods for logarithmic, trigonometric, and mathematical functions.
Code example
This is a code example for Runtime::Math.
double a= Runtime::Math.Abs(-4.5); //a= 4.5;
double angle= Runtime::Math.Acos(0); //angle= 1.5707963267949;
double angle= Runtime::Math.Asin(0); //angle=0;
double angle= Runtime::Math.Atan(0); //angle=0;
double angle =Runtime::Math.Atan2(1,1); // angle= 0.785398163397448;
double a= Runtime::Math.Ceiling(0.2); //a=1;
double a= Runtime::Math.Clamp(3,0,1); //a=1;
double cosine= Runtime::Math.Cos(0); //cosine=1;
double anglerad =Runtime::Math.DegToRad(45); // anglerad= 0.785398163397448;
double a= Runtime::Math.E; //a= 2.71828182845905;
double a= Runtime::Math.Exp(2); // a=7.38905609893065
double a= Runtime::Math.Floor(0.2); //a=0;
double a= Runtime::Math.Max(0.2,5.3); //a=5.3;
double a= Runtime::Math.Min(0.2,5.3); //a=0.2;
double a= Runtime::Math.PI; //a= 3.14159265358979;
double angledeg =Runtime::Math.RadToDeg(0.785398163397448); // angledeg= 45;
double a= Runtime::Math.Round(2.5); //a=3;
double sine= Runtime::Math.Sin(0); //sine=0;
double sine= Runtime::Math.Sqrt(9); //sine=3;
double angle= Runtime::Math.Tan(0.785398163397448); //angle=0.999999999999999;
double sign= Runtime::Math.Sign(45); //sign=1;
double sine= Runtime::Math.Truncate(2.5); //a=2;
Runtime::Environment.Print(Runtime::Math.Abs(-Runtime::Math.PI)); //3.14159265358979
Methods
The following table shows the currently implemented methods.
|
Method |
Return type |
Parameters |
Description |
|---|---|---|---|
|
Abs |
double |
numerical value |
Calculates the absolute value of a numerical value. |
|
Acos |
double |
double value |
Calculates the angle, in radians, whose cosine is value. The value must be in the range [-1 1], otherwise return value is NaN. |
|
Asin |
double |
double value |
Calculates the angle, in radians, whose sine is value. The value must be in the range [-1 1], otherwise return value is NaN. |
|
Atan |
double |
double value |
Calculates the angle, in radians, whose tangent is value. The resulting angle is in the range [-π/2 π/2]. Return value is NaN id value is equal to NaN. |
|
Atan2 |
double |
double y, double x |
Calculates the angle, in radians, whose tangent is the quotient of y and x. The two parameters represents the coordinate (x,y) of a point in the Cartesian plane. The resulting angle is:
|
|
Ceiling |
double |
double value |
Calculates the smallest integral value greater than or equal to value. |
|
Clamp |
numerical |
numerical value, numerical min, numerical max |
Calculates value clamped to the inclusive range of min and max. The value,min and max can be int or double, but they must be the same value type. |
|
Cos |
double |
double angle |
Calculates the cosine of angle. The angle is in radians. |
|
DegToRad |
double |
double angle |
Converts angle from degrees to radians. |
|
E |
double |
|
Returns the natural logarithmic base. |
|
Exp |
double |
double value |
Returns the natural logarithmic base raised to value. |
|
Floor |
double |
double value |
Calculates the largest integral value less than or equal to value. |
|
Max |
numerical |
numerical a numerical b |
Returns the larger number among a and b. a and b can be int or double, but they must be the same value type. |
|
Min |
numerical |
numerical a numerical b |
Returns the smaller number among a and b. a and b can be int or double, but they must be the same value type. |
|
PI |
double |
|
Returns the value of π. |
|
RadToDeg |
double |
double angle |
Converts angle from radians to degrees. |
|
Round |
double |
double value |
Rounds value to the nearest integer. |
|
Sign |
double |
numerical value |
Calculates the sign of value and returns 1 if the number is positive, 0 if it is zero or -1 if it is negative. |
|
Sin |
double |
double angle |
Calculates the sine of angle. angle is in radians. |
|
Sqrt |
double |
double value |
Calculates the square root of value. The square root of a negative number returns NaN. |
|
Tan |
double |
double angle |
Calculates the tangent of angle. angle is in radians. |
|
Truncate |
double |
double value |
Rounds value to the nearest smaller integer. |