A utility class providing various mathematical functions.
While most methods exposed by this class take untyped parameters by definition, they in fact can only handle certain number types, i.e. int, byte and float. If an argument of non-numeral type is passed in, it will in most cases result in System.ArgumentException.
Parent Class
Type | Name | Signature |
---|---|---|
field S C | PI | public static const float PI |
field S C | E | public static const float E |
field S C | INF | public static const float INF |
field S C | NINF | public static const float NINF |
method S | abs | public static var abs(var) |
method S | arccos | public static float arccos(var) |
method S | arcsin | public static float arcsin(var) |
method S | arctan | public static float arctan(var) |
method S | ceil | public static int ceil(var) |
method S | cos | public static float cos(var) |
method S | floor | public static int floor(var) |
method S | isNumber | public static bool isNumber(var) |
method S | log | public static float log(var) |
method S | log10 | public static float log10(var) |
method S | log2 | public static float log2(var) |
method S | max | public static var max(var, var) |
method S | min | public static var min(var, var) |
method S | power | public static var power(var, var) |
method S | round | public static int round(var) |
method S | sign | public static byte sign(var) |
method S | sin | public static float sin(var) |
method S | sqrt | public static float sqrt(var) |
method S | tan | public static float tan(var) |
public static const float PI
The ratio of a circle's circumference to its diameter.
public static const float E
The base of the natural logarithms.
public static const float INF
The positive infinity of float number.
public static const float NINF
The negative infinity of float number.
public static var abs(var v)
Get the absolute value of the numeral argument.
Parameters
Returns
Throws
public static float arccos(var v)
Get the inverse cosine of the given numeral argument.
Parameters
Returns
Throws
public static float arcsin(var v)
Get the inverse sine of the given numeral argument.
Parameters
Returns
Throws
public static float arctan(var v)
Get the inverse tangent of the given numeral argument.
Parameters
Returns
Throws
public static int ceil(var v)
Get the smallest integer that is greater than or equal to the numeral argument.
Parameters
Returns
Throws
public static float cos(var v)
Get the trigonometric cosine of the given numeral argument.
Parameters
Returns
Throws
public static int floor(var v)
Get the largest integer that is less than or equal to the numeral argument.
Parameters
Returns
Throws
public static bool isNumber(var v)
Check whether a value is a number. A value of int or byte type is a number. A float value is usually also a number except if it explicitly represents Not-A-Number, which can happen when an arithmetic expression yielded illegal intermediate or final result.
Parameters
Returns
public static float log(var v)
Get the natural logarithm (with base = e) of the given numeral argument.
This class also provides two convenient log methods for base-2 and base-10. To perform logarithm calculation of arbitrary base B, simply do log(x)/log(B)
.
Parameters
Returns
Throws
public static float log10(var v)
Get the logarithm with base = 10 of the given numeral argument.
Parameters
Returns
Throws
public static float log2(var v)
Get the logarithm with base = 2 of the given numeral argument.
Parameters
Returns
Throws
public static var max(var v1, var v2)
Get the larger one from the two arguments. If the two are equal the same value will be returned.
Parameters
Returns
Throws
public static var min(var v1, var v2)
Get the smaller one from the two arguments. If the two are equal the same value will be returned.
Parameters
Returns
Throws
public static var power(var a, var b)
Raise one value to the power of another.
Parameters
Returns
Throws
public static int round(var v)
Get the closest integer to the numeral argument.
The given value will be rounded half towards positive infinity. This means for a positive number, if the decimal part is equal to or greater than 0.5, it will be rounded up; otherwise rounded down. For a negative number, if the decimal part is equal to or less than -0.5, it will be rounded up; otherwise rounded down. Some examples: round(1.4) = 1, round(1.5) = 2, round(1.6) = 2; round(-1.4) = -1, round(-1.5) = -1, round(-1.6) = -2.
Parameters
Returns
Throws
public static byte sign(var v)
Get the sign part of the given numeral argument.
Parameters
Returns
Throws
public static float sin(var v)
Get the trigonometric sine of the given numeral argument.
Parameters
Returns
Throws
public static float sqrt(var v)
Get the square root of the given numeral argument.
Parameters
Returns
Throws
public static float tan(var v)
Get the trigonometric tangent of the given numeral argument.
Parameters
Returns
Throws