You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== math_const ==
Copy Code
The output would be:
Returns the value of various math constants. The constant argument must be one of the following: NaN, NEGATIVE_INFINITY, INFINITY, DOUBLE_MAX, DOUBLE_MIN, LONG_MAX, LONG_MIN, SHORT_MAX, SHORT_MIN, INTEGER_MAX, INTEGER_MIN, FLOAT_MAX, FLOAT_MIN, BYTE_MAX, BYTE_MIN, E, PI, PHI, C, or EULER
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| math_const
|-
! scope="row" | Returns
| number
|-
! scope="row" | Usages
| constant
|-
! scope="row" | Throws
| [[../objects/ms.lang.CastException|ms.lang.CastException]]
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| [[../../Optimizer#CONSTANT_OFFLINE|CONSTANT_OFFLINE]]
|}The following table lists the values, and a brief description of each:
{| cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! Constant Name
! Description
! Value
|-
| NaN
| A representation of an undefined number (Not a Number), per the IEEE 754 standard
| NaN
|-
| NEGATIVE_INFINITY
| A representation of negative infinity, per the IEEE 754 standard
| -Infinity
|-
| INFINITY
| A representation of positive infinity, per the IEEE 754 standard
| Infinity
|-
| DOUBLE_MAX
| The highest number that can be represented as a double
| 1.7976931348623157E308
|-
| DOUBLE_MIN
| The lowest number that can be represented as a double
| 4.9E-324
|-
| LONG_MAX
| The highest number that can be represented as a long
| 9223372036854775807
|-
| LONG_MIN
| The lowest number that can be represented as a long
| -9223372036854775808
|-
| SHORT_MAX
| The highest number that can be represented as a short
| 32767
|-
| SHORT_MIN
| The lowest number that can be represented as a short
| -32768
|-
| INTEGER_MAX
| The highest number that can be represented as a integer
| 2147483647
|-
| INTEGER_MIN
| The lowest number that can be represented as an integer
| -2147483648
|-
| FLOAT_MAX
| The highest number that can be represented as a float
| 3.4028235E38
|-
| FLOAT_MIN
| The lowest number that can be represented as a float
| 1.4E-45
|-
| BYTE_MAX
| The highest number that can be represented as a byte
| 127
|-
| BYTE_MIN
| The lowest number that can be represented as a byte
| -128
|-
| E
| The mathematical constant e, also known as Euler's number (not to be confused with the Euler-Mascheroni constant)
| 2.718281828459045
|-
| PI
| The value of π (pi)
| 3.141592653589793
|-
| PHI
| The golden ratio
| 1.618033988749895
|-
| C
| The speed of light in a vacuum, in meters per second
| 2.99792458E8
|-
| EULER
| The Euler-Mascheroni constant γ (not to be confused with e)
| 0.5772156649015627
|}
Note that this function is optimized, and when given a constant value for the parameter, is resolved at compile time.
=== Usages ===
math_const(constant)=== Examples === ====Example 1==== Basic usage Given the following code:
math_const('PI');

1 {{function|math_const}}('PI');
:3.141592653589793
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)