This class defines mathematical functions and constants.

See:

`static read only NEGATIVE_INFINITY:Float`

*Available on cpp, cs, flash, hl, java, macro, neko, php, python*

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.

`static read only NEGATIVE_INFINITY:Float`

*Available on js, lua*

`static read only NaN:Float`

*Available on cpp, cs, flash, hl, java, macro, neko, php, python*

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.

@php In PHP versions prior to 5.3.1 VC 9 there may be unexpected results when performing arithmetic operations with `NaN`

on Windows, see https://bugs.php.net/bug.php?id=42143

`static read only NaN:Float`

*Available on js, lua*

`static read only PI:Float`

*Available on cpp, cs, flash, hl, java, js, macro, neko, php, python*

Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. `PI`

is approximately 3.141592653589793.

`static read only PI:Float`

*Available on lua*

`static read only POSITIVE_INFINITY:Float`

*Available on cpp, cs, flash, hl, java, macro, neko, php, python*

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.

`static read only POSITIVE_INFINITY:Float`

*Available on js, lua*

`static abs (v:Float):Float`

Returns the absolute value of `v`

.

If `v`

is positive or 0, the result is unchanged. Otherwise the result is -`v`

.

If `v`

is `NEGATIVE_INFINITY`

or `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

.

If `v`

is `NaN`

, the result is `NaN`

.

`static acos (v:Float):Float`

Returns the trigonometric arc cosine of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

`static asin (v:Float):Float`

Returns the trigonometric arc of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

`static atan (v:Float):Float`

Returns the trigonometric arc tangent of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

`static atan2 (y:Float, x:Float):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`

.

`static ceil (v:Float):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.

`static cos (v:Float):Float`

Returns the trigonometric cosine of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

`static exp (v:Float):Float`

Returns Euler's number, raised to the power of `v`

.

exp(1.0) is approximately 2.718281828459.

If `v`

is `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

. If `v`

is `NEGATIVE_INFINITY`

, the result is `0.0`

. If `v`

is `NaN`

, the result is `NaN`

.

`static fceil (v:Float):Float`

Returns 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.

`static ffloor (v:Float):Float`

Returns 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.

`static floor (v:Float):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.

`static fround (v:Float):Float`

Rounds `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.

`static isFinite (f:Float):Bool`

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`

.

`static isNaN (f:Float):Bool`

Tells 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`

.

`static log (v:Float):Float`

Returns the natural logarithm of `v`

.

This is the mathematical inverse operation of exp, i.e. `log(exp(v)) == v`

always holds.

If `v`

is negative (including `NEGATIVE_INFINITY`

) or `NaN`

, the result is `NaN`

. If `v`

is `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

. If `v`

is `0.0`

, the result is `NEGATIVE_INFINITY`

.

`static max (a:Float, b:Float):Float`

Returns the greater of values `a`

and `b`

.

If `a`

or `b`

are `NaN`

, the result is `NaN`

. If `a`

or `b`

are `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

. If `a`

and `b`

are `NEGATIVE_INFINITY`

, the result is `NEGATIVE_INFINITY`

.

`static min (a:Float, b:Float):Float`

Returns the smaller of values `a`

and `b`

.

If `a`

or `b`

are `NaN`

, the result is `NaN`

. If `a`

or `b`

are `NEGATIVE_INFINITY`

, the result is `NEGATIVE_INFINITY`

. If `a`

and `b`

are `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

.

`static pow (v:Float, exp:Float):Float`

Returns a specified base `v`

raised to the specified power `exp`

.

`static random ():Float`

Returns a pseudo-random number which is greater than or equal to 0.0, and less than 1.0.

`static round (v:Float):Int`

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.

`static sin (v:Float):Float`

Returns the trigonometric sine of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

`static sqrt (v:Float):Float`

Returns the square root of `v`

.

If `v`

is negative (including `NEGATIVE_INFINITY`

) or `NaN`

, the result is `NaN`

. If `v`

is `POSITIVE_INFINITY`

, the result is `POSITIVE_INFINITY`

. If `v`

is `0.0`

, the result is `0.0`

.

`static tan (v:Float):Float`

Returns the trigonometric tangent of the specified angle `v`

, in radians.

If `v`

is `NaN`

or infinite, the result is `NaN`

.

© 2005–2018 Haxe Foundation

Licensed under a MIT license.

https://api.haxe.org/Math.html