Symbolic Math Constants

The following symbolic constants are available.

Built-in Math Constants

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 built-in math functions.
INFINITY A constant expression of type float representing positive or unsigned infinity.
NAN A constant expression of type float representing a quiet NaN.

Double Math Constants

The following constants are also available if the built-in math functions are extended with cl_khr_fp64. 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 log2e
M_LOG10E Value of log10e
M_LN2 Value of loge2
M_LN10 Value of loge10
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)


OpenCL Specification

Also see

Math Functions, Floating Point Pragma, Macros and Limits

Copyright © 2007-2009 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.