Math
This class defines mathematical functions and constants.
Static Members
PI: FloatRepresents the ratio of the circumference of a circle to its diameter,
specified by the constant, π. PI is approximately 3.141592653589793.
NaN: FloatA special Float constant which denotes an invalid number.
NaN stands for "Not a Number". It occurs when a mathematically incorrect
operation is executed, such as taking the square root of a negative
number: Math.sqrt(-1).
All further operations with NaN as an operand will result in NaN.
If this constant is converted to an Int, e.g. through Std.int(), the
result is unspecified.
In order to test if a value is NaN, you should use Math.isNaN() function.
NEGATIVE_INFINITY: FloatA special Float constant which denotes negative infinity.
For example, this is the result of -1.0 / 0.0.
Operations with NEGATIVE_INFINITY as an operand may result in
NEGATIVE_INFINITY, POSITIVE_INFINITY or NaN.
If this constant is converted to an Int, e.g. through Std.int(), the
result is unspecified.
POSITIVE_INFINITY: FloatA special Float constant which denotes positive infinity.
For example, this is the result of 1.0 / 0.0.
Operations with POSITIVE_INFINITY as an operand may result in
NEGATIVE_INFINITY, POSITIVE_INFINITY or NaN.
If this constant is converted to an Int, e.g. through Std.int(), the
result is unspecified.
Returns the absolute value of v.
- If
vis positive or0, the result is unchanged. Otherwise the result is-v. - If
visNEGATIVE_INFINITYorPOSITIVE_INFINITY, the result isPOSITIVE_INFINITY. - If
visNaN, the result isNaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns the smaller of values a and b.
- If
aorbareNaN, the result isNaN. - If
aorbareNEGATIVE_INFINITY, the result isNEGATIVE_INFINITY. - If
aandbarePOSITIVE_INFINITY, the result isPOSITIVE_INFINITY.
| Name | Type |
|---|---|
a |
Float |
b |
Float |
| Returns |
|---|
| Float |
Returns the greater of values a and b.
- If
aorbareNaN, the result isNaN. - If
aorbarePOSITIVE_INFINITY, the result isPOSITIVE_INFINITY. - If
aandbareNEGATIVE_INFINITY, the result isNEGATIVE_INFINITY.
| Name | Type |
|---|---|
a |
Float |
b |
Float |
| Returns |
|---|
| Float |
Returns the trigonometric sine of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns the trigonometric cosine of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns the trigonometric arc tangent whose tangent is the quotient of two specified numbers, in radians.
If parameter x or y is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY,
the result is NaN.
| Name | Type |
|---|---|
y |
Float |
x |
Float |
| Returns |
|---|
| Float |
Returns Euler's number, raised to the power of v.
exp(1.0) is approximately 2.718281828459.
- If
visPOSITIVE_INFINITY, the result isPOSITIVE_INFINITY. - If
visNEGATIVE_INFINITY, the result is0.0. - If
visNaN, the result isNaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns the square root of v.
- If
vis negative (includingNEGATIVE_INFINITY) orNaN, the result isNaN. - If
visPOSITIVE_INFINITY, the result isPOSITIVE_INFINITY. - If
vis0.0, the result is0.0.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Rounds v to the nearest integer value.
Ties are rounded up, so that 0.5 becomes 1 and -0.5 becomes 0.
If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY
or POSITIVE_INFINITY, the result is unspecified.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Int |
Returns the largest integer value that is not greater than v.
If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY
or POSITIVE_INFINITY, the result is unspecified.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Int |
Returns the smallest integer value that is not less than v.
If v is outside of the signed Int32 range, or is NaN, NEGATIVE_INFINITY
or POSITIVE_INFINITY, the result is unspecified.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Int |
Returns the trigonometric arc of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns the trigonometric arc cosine of the specified angle v,
in radians.
If v is NaN or infinite, the result is NaN.
| Name | Type |
|---|---|
v |
Float |
| Returns |
|---|
| Float |
Returns a specified base v raised to the specified power exp.
| Name | Type |
|---|---|
v |
Float |
exp |
Float |
| Returns |
|---|
| Float |
random(): FloatReturns a pseudo-random number which is greater than or equal to 0.0,
and less than 1.0.
| Returns |
|---|
| Float |
Tells if f is a finite number.
If f is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN, the result
is false, otherwise the result is true.
| Name | Type |
|---|---|
f |
Float |
| Returns |
|---|
| Bool |
Tells if f is Math.NaN.
If f is NaN, the result is true, otherwise the result is false.
In particular, null, POSITIVE_INFINITY and NEGATIVE_INFINITY are
not considered NaN.
| Name | Type |
|---|---|
f |
Float |
| Returns |
|---|
| Bool |
Private Members
rand: cs.system.RandomMetadata
| Name | Parameters |
|---|---|
:nativeGen |
- |
:nativeGen |
- |