---
name: "mathConstants"
section: "3clc"
platform: "linux"
package: "opencl-1.2-man-doc"
version: "1.0~svn33624-5.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mathConstants"
---

# mathConstants(3clc)

The following symbolic constants are available.

## NAME

Symbolic\_Math\_Constants - The following symbolic constants are available.

## BUILT-IN MATH CONSTANTS

The following symbolic constants are available. Their values are of type **float** and are accurate within the precision of a single precision floating-point number.

| | |
| --- | --- |
| **Constant Name** | **Description** |
| MAXFLOAT | Value of maximum non-infinite single-precision floating-point number. |
| HUGE\_VALF | A positive float constant expression. **HUGE\_VALF** evaluates to +infinity. Used as an error value returned by the [**mathFunctions**(3clc)](/mathFunctions/3clc.md). |
| INFINITY | A constant expression of type **float** representing positive or unsigned infinity. |
| NAN | A constant expression of type **float** representing a quiet NaN. |

If double precision is supported by the device, the following symbolic constant will also be available:

| | |
| --- | --- |
| **Constant Name** | **Description** |
| HUGE\_VAL | A positive double constant expression. **HUGE\_VAL** evaluates to +infinity. Used as an error value returned by the built-in math functions. |

The following constants are also available. They are of type **float** and are accurate within the precision of the **float** type.

| | |
| --- | --- |
| **Constant Name** | **Description** |
| M\_E\_F | Value of e |
| M\_LOG2E\_F | Value of log\<sub\>2\</sub\>e |
| M\_LOG10E\_F | Value of log\<sub\>10\</sub\>e |
| M\_LN2\_F | Value of log\<sub\>e\</sub\>2 |
| M\_LN10\_F | Value of log\<sub\>e\</sub\>10 |
| M\_PI\_F | Value of pi |
| M\_PI\_2\_F | Value of pi / 2 |
| M\_PI\_4\_F | Value of pi / 4 |
| M\_1\_PI\_F | Value of 1 / pi |
| M\_2\_PI\_F | Value of 2 / pi |
| M\_2\_SQRTPI\_F | Value of 2 / (square root of pi) |
| M\_SQRT2\_F | Value of square root of 2 |
| M\_SQRT1\_2\_F | Value of 1 / (square root of 2) |

If double precision is supported by the device, the following macros and constants are also available. They are of type **double** and are accurate within the precision of the **double** type.

| | |
| --- | --- |
| **Constant Name** | **Description** |
| M\_E | Value of e |
| M\_LOG2E | Value of log\<sub\>2\</sub\>e |
| M\_LOG10E | Value of log\<sub\>10\</sub\>e |
| M\_LN2 | Value of log\<sub\>e\</sub\>2 |
| M\_LN10 | Value of log\<sub\>e\</sub\>10 |
| M\_PI | Value of pi |
| M\_PI\_2 | Value of pi / 2 |
| M\_PI\_4 | Value of pi / 4 |
| M\_1\_PI | Value of 1 / pi |
| M\_2\_PI | Value of 2 / pi |
| M\_2\_SQRTPI | Value of 2 / (square root of pi) |
| M\_SQRT2 | Value of square root of 2 |
| M\_SQRT1\_2 | Value of 1 / (square root of 2) |

The following constants are also available. They are of type **half** and are accurate within the precision of the **half** type. An application that wants to use **half** and **half***n* types will need to include the #pragma OPENCL EXTENSION [**cl\_khr\_fp16**(3clc)](/cl_khr_fp16/3clc.md) : enable directive.

| | |
| --- | --- |
| **Constant** | **Description** |
| M\_E\_H | Value of e |
| M\_LOG2E\_H | Value of log\<sub\>2\</sub\>e |
| M\_LOG10E\_H | Value of log\<sub\>10\</sub\>e |
| M\_LN2\_H | Value of log\<sub\>e\</sub\>2 |
| M\_LN10\_H | Value of log\<sub\>e\</sub\>10 |
| M\_PI\_H | Value of pi |
| M\_PI\_2\_H | Value of pi / 2 |
| M\_PI\_4\_H | Value of pi / 4 |
| M\_1\_PI\_H | Value of 1 / pi |
| M\_2\_PI\_H | Value of 2 / pi |
| M\_2\_SQRTPI\_H | Value of 2 / (square root of pi) |
| M\_SQRT2\_H | Value of square root of 2 |
| M\_SQRT1\_2\_H | Value of 1 / (square root of 2) |

## SPECIFICATION

**OpenCL Specification**\[1\]

## SEE ALSO

[**mathFunctions**(3clc)](/mathFunctions/3clc.md), [**FP\_CONTRACT**(3clc)](/FP_CONTRACT/3clc.md), [**macroLimits**(3clc)](/macroLimits/3clc.md)

## AUTHORS

**The Khronos Group**

## COPYRIGHT

Copyright © 2007-2011 The Khronos Group Inc.\
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.

## NOTES

- 1\.

  OpenCL Specification

  page 251, section 6.12.2 - Table at end of Math Functions
