Math constants
Math constants
Function
Math provides commonly used mathematical constants, which can be read in attribute form.
Syntax
Math.PI Math.E Math.TAU
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| None | - | No | None | Constant properties require no parameters. |
Return value
| Type | Description |
|---|---|
| Int/Float | Returns the corresponding mathematical constant. |
Constant list
| Constant | Description |
|---|---|
| Math.E | The natural constant e. |
| Math.LN2 | The natural logarithm of 2. |
| Math.LN10 | The natural logarithm of 10. |
| Math.LOG2E | The base 2 logarithm of e. |
| Math.LOG10E | Base 10 logarithm of e. |
| Math.PI | Pi. |
| Math.SQRT1_2 | The reciprocal of the square root of 2. |
| Math.SQRT2 | The square root of 2. |
| Math.TAU | 2 times pi. |
Example
// Output: 3.141592653589793 print Math.PI // Output: 2.718281828459045 print Math.E // Output: 6.283185307179586 print Math.TAU
Notes
- Math constants are read-only static properties and do not require calling math() to create objects.