Available on all platforms
This class defines mathematical functions and constants.
See also:
staticread onlyNEGATIVE_INFINITY:Float = cs.system.Double.NegativeInfinityAvailable on cs, php, neko, cpp, macro, java, python, hl, flash
A 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.
staticread onlyNEGATIVE_INFINITY:FloatAvailable on js, lua
staticread onlyNaN:Float = cs.system.Double.NaNAvailable on cs, php, neko, cpp, macro, java, python, hl, flash
A 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.
staticread onlyNaN:FloatAvailable on js, lua
staticread onlyPI:Float = cs.system.Math.PIAvailable on cs, php, js, neko, cpp, macro, java, python, hl, flash
Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. PI is approximately 3.141592653589793.
staticread onlyPI:FloatAvailable on lua
staticread onlyPOSITIVE_INFINITY:Float = cs.system.Double.PositiveInfinityAvailable on cs, php, neko, cpp, macro, java, python, hl, flash
A 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.
staticread onlyPOSITIVE_INFINITY:FloatAvailable on js, lua
staticabs(v:Float):FloatReturns the absolute value of v.
v is positive or 0, the result is unchanged. Otherwise the result is -v.v is NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is POSITIVE_INFINITY.v is NaN, the result is NaN.staticacos(v:Float):FloatReturns the trigonometric arc cosine of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
staticasin(v:Float):FloatReturns the trigonometric arc of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
staticatan(v:Float):FloatReturns the trigonometric arc tangent of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
staticatan2(y:Float, x:Float):FloatReturns 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.
staticceil(v:Float):IntReturns 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.
staticcos(v:Float):FloatReturns the trigonometric cosine of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
staticexp(v:Float):FloatReturns Euler's number, raised to the power of v.
exp(1.0) is approximately 2.718281828459.
v is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.v is NEGATIVE_INFINITY, the result is 0.0.v is NaN, the result is NaN.staticfceil(v:Float):FloatReturns the smallest integer value that is not less than v, as a Float.
If v is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
staticffloor(v:Float):FloatReturns the largest integer value that is not greater than v, as a Float.
If v is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
staticfloor(v:Float):IntReturns 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.
staticfround(v:Float):FloatRounds v to the nearest integer value, as a Float.
Ties are rounded up, so that 0.5 becomes 1 and -0.5 becomes 0.
If v is is NaN, NEGATIVE_INFINITY or POSITIVE_INFINITY, the result is unspecified.
staticisFinite(f:Float):BoolTells if f is a finite number.
If f is POSITIVE_INFINITY, NEGATIVE_INFINITY or NaN, the result is false, otherwise the result is true.
staticisNaN(f:Float):BoolTells if f is not a valid number.
If f is NaN, the result is true, otherwise the result is false. In particular, both POSITIVE_INFINITY and NEGATIVE_INFINITY are not considered NaN.
staticlog(v:Float):FloatReturns the natural logarithm of v.
This is the mathematical inverse operation of exp, i.e. log(exp(v)) == v always holds.
v is negative (including NEGATIVE_INFINITY) or NaN, the result is NaN.v is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.v is 0.0, the result is NEGATIVE_INFINITY.staticmax(a:Float, b:Float):FloatReturns the greater of values a and b.
a or b are NaN, the result is NaN.a or b are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.a and b are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.staticmin(a:Float, b:Float):FloatReturns the smaller of values a and b.
a or b are NaN, the result is NaN.a or b are NEGATIVE_INFINITY, the result is NEGATIVE_INFINITY.a and b are POSITIVE_INFINITY, the result is POSITIVE_INFINITY.staticpow(v:Float, exp:Float):FloatReturns a specified base v raised to the specified power exp.
staticrandom():FloatReturns a pseudo-random number which is greater than or equal to 0.0, and less than 1.0.
staticround(v:Float):IntRounds 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.
staticsin(v:Float):FloatReturns the trigonometric sine of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
staticsqrt(v:Float):FloatReturns the square root of v.
v is negative (including NEGATIVE_INFINITY) or NaN, the result is NaN.v is POSITIVE_INFINITY, the result is POSITIVE_INFINITY.v is 0.0, the result is 0.0.statictan(v:Float):FloatReturns the trigonometric tangent of the specified angle v, in radians.
If v is NaN or infinite, the result is NaN.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/Math.html